Examples of WebService


Examples of javax.jws.WebService

       
        QName ret = null;
       
        if (isServiceProvider()) {
            if (serviceName == null) {
                WebService ws = (WebService)serviceImplementation.getClass().getAnnotation(WebService.class);
                serviceName = new QName(ws.targetNamespace(), ws.serviceName());
            }
            ret = serviceName;
        }
        return ret;
    }
View Full Code Here

Examples of javax.jws.WebService

   
    Document getWsdlAsDocument() {
       
        Document doc = null;
        try {
            WebService ws = serviceImplementation.getClass().getAnnotation(WebService.class);
            if (ws != null) {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                factory.setNamespaceAware(true);
                DocumentBuilder builder = factory.newDocumentBuilder();
                doc = builder.parse(ws.wsdlLocation());
            } else {
                LOG.severe("could not get WebService annotation from " + serviceImplementation);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
View Full Code Here

Examples of javax.jws.WebService

            Method targetMethod = (Method)context.get(ObjectMessageContext.METHOD_OBJ);
            Class<?> clz = targetMethod.getDeclaringClass();
           
            LOG.fine("invoking service " + clz);
           
            WebService ws = clz.getAnnotation(WebService.class);
            assert ws != null;
            QName interfaceName = new QName(ws.targetNamespace(), ws.name());
           
            MessageExchangeFactory factory = channel.createExchangeFactoryForService(serviceName);
            LOG.fine("create message exchange svc: " + serviceName);
            InOut xchng = factory.createInOutExchange();
           
View Full Code Here

Examples of javax.jws.WebService

        assertTrue("class " + clz.getName() + " modifier is not public", Modifier
                   .isPublic(clz.getModifiers()));
        assertTrue("class " + clz.getName() + " modifier is interface",
                   Modifier.isInterface(clz.getModifiers()));

        WebService webServiceAnn = AnnotationUtil.getPrivClassAnnotation(clz, WebService.class);
        assertEquals("Greeter", webServiceAnn.name());

        Method method = clz.getMethod("sayHi", new Class[] {});
        WebMethod webMethodAnno = AnnotationUtil.getPrivMethodAnnotation(method, WebMethod.class);
        assertEquals(method.getName() + "()" + " Annotation : WebMethod.operationName ", "sayHi",
                     webMethodAnno.operationName());
View Full Code Here

Examples of javax.jws.WebService

        }
        checkWebMethodUseClass(clz.getSuperclass());
    }

    private void populateWSDLInfo(Class clazz) {
        WebService webService = AnnotationUtil.getPrivClassAnnotation(clazz, WebService.class);
        if (webService == null) {
            Message message = new Message("SEI_CLASS_NO_WEBSERVICE_ANNOTATED", LOG);
            throw new ToolException(message);

        }
        if (webService.endpointInterface().length() > 0) {
            clazz = AnnotationUtil.loadClass(webService.endpointInterface(), clazz.getClassLoader());
            webService = AnnotationUtil.getPrivClassAnnotation(clazz, WebService.class);
            if (webService == null) {
                Message message = new Message("SEI_INTERFACE_NO_WEBSERVICE_ANNOTATED", LOG);
                throw new ToolException(message);
            }
        }

        String portTypeName = clazz.getSimpleName() + "PortType";
        if (webService.name().length() > 0) {
            portTypeName = webService.name();
        }

        model.setPortTypeName(portTypeName);

        String portName = clazz.getSimpleName() + "Port";

        if (webService.portName().length() > 0) {
            portName = webService.portName();
        } else if (webService.name().length() > 0) {
            portName = webService.name() + "Port";

        }
        model.setPortName(portName);

        String serviceName = clazz.getSimpleName() + "Service";
        if (env.optionSet(ToolConstants.CFG_SERVICENAME)) {
            serviceName = (String)env.get(ToolConstants.CFG_SERVICENAME);
        } else {
            if (webService.serviceName().length() > 0) {
                serviceName = webService.serviceName();
            }
        }
        model.setServiceName(serviceName);

        String packageName = "";
        if (clazz.getPackage() != null) {
            packageName = clazz.getPackage().getName();
        }
        model.setPackageName(packageName);

        String targetNamespace = URIParserUtil.getNamespace(packageName);
        if (env.optionSet(ToolConstants.CFG_TNS)) {
            targetNamespace = (String)env.get(ToolConstants.CFG_TNS);
        } else if (webService.targetNamespace().length() > 0) {
            targetNamespace = webService.targetNamespace();
        } else if (targetNamespace == null) {
            Message message = new Message("SEI_CLASS_HASNO_PACKAGE", LOG);
            throw new ToolException(message);
        }

        model.setTargetNameSpace(targetNamespace);
        String wsdlLocation = webService.wsdlLocation();
        model.setWsdllocation(wsdlLocation);

        javax.jws.soap.SOAPBinding soapBinding = AnnotationUtil
            .getPrivClassAnnotation(clazz, javax.jws.soap.SOAPBinding.class);
        if (soapBinding != null) {
View Full Code Here

Examples of javax.jws.WebService

     */
    public static WebService getWebServiceAnnotation(Class<?> cls) {
        if (cls == null) {
            return null;
        }
        WebService ws = cls.getAnnotation(WebService.class);
        if (null != ws) {
            return ws;
        }
        for (Class<?> inf : cls.getInterfaces()) {
            ws = getWebServiceAnnotation(inf);
View Full Code Here

Examples of javax.jws.WebService

     * @throws WSDLException
     */
    public static EndpointReferenceType getEndpointReference(WSDLManager manager,
                                                                 Class<?> implementorClass) {

        WebService ws = getWebServiceAnnotation(implementorClass);

        WebServiceProvider wsp = null;
        if (null == ws) {
            wsp = implementorClass.getAnnotation(WebServiceProvider.class);
            if (null == wsp) {
                return null;
            }
        }

        EndpointReferenceType reference = new EndpointReferenceType();
        reference.setMetadata(new MetadataType());
        String serviceName = (null != ws) ? ws.serviceName() : wsp.serviceName();
        String targetNamespace = (null != ws) ? ws.targetNamespace() : wsp.targetNamespace();
        String portName = (null != ws) ? ws.portName() : wsp.portName();
        String url = (null != ws) ? ws.wsdlLocation() : wsp.wsdlLocation();
        String className = (null != ws) ? ws.endpointInterface() : null;
    
        QName portTypeName = null;
        if (null != className && !"".equals(className)) {
            Class<?> seiClazz = null;
            try {
                seiClazz = Class.forName(className);
            } catch (ClassNotFoundException cnfe) {
                LOG.log(Level.SEVERE, "SEI_LOAD_FAILURE_MSG", cnfe);
                throw new WebServiceException("endpointInterface element in WebService annotation invalid",
                                              cnfe);
            }
           
            if (!seiClazz.isInterface()) {
                throw new WebServiceException("endpointInterface element does not refer to a java interface");
            }
           
            WebService seiws = seiClazz.getAnnotation(WebService.class);
            if (null == seiws) {
                throw new WebServiceException("SEI should have a WebService Annotation");
            }

            if ("".equals(url)) {
                url = seiws.wsdlLocation();
            }

            //WebService.name maps to wsdl:portType name.
            portTypeName = new QName(ws.targetNamespace(), seiws.name());

            //ServiceName,portName,endpointInterface not allowed on the WebService annotation
            // of a SEI, Section 3.2 JSR181.
            // set interfaceName using WebService.targetNamespace of SEI only.
        } else {
View Full Code Here

Examples of javax.jws.WebService

  public BusinessService readServiceAnnotations(String classWithAnnotations, Properties properties) throws ClassNotFoundException {
   
    BusinessService service = new BusinessService();
    Class<?> clazz = Loader.loadClass(classWithAnnotations);
    UDDIService uddiService= (UDDIService) clazz.getAnnotation(UDDIService.class);
    WebService webServiceAnnotation = (WebService) clazz.getAnnotation(WebService.class);
   
    if (uddiService!=null) {
      //service
      String lang = "en"; //default to english
      if (uddiService.lang()!=null) {
        lang = uddiService.lang();
      }
      Name name = new Name();
      name.setLang(lang);
      service.setBusinessKey(TokenResolver.replaceTokens(uddiService.businessKey(),properties));
      service.setServiceKey(TokenResolver.replaceTokens(uddiService.serviceKey(),properties));
      if (!"".equals(uddiService.serviceName())) {
        name.setValue(TokenResolver.replaceTokens(uddiService.serviceName(),properties));
      } else if (webServiceAnnotation!=null && !"".equals(webServiceAnnotation.serviceName())) {
        name.setValue(webServiceAnnotation.serviceName());
      } else {
        name.setValue(clazz.getSimpleName());
      }
      service.getName().add(name);
      Description description = new Description();
View Full Code Here

Examples of javax.jws.WebService

    for (Class<?> ifc : serviceClass.getInterfaces()) {
      if (ifc.isAnnotationPresent(Remote.class))
        return ifc;
    }
   
    WebService webService
      = (WebService) serviceClass.getAnnotation(WebService.class);

    if (webService != null && ! "".equals(webService.endpointInterface())) {
      ClassLoader loader = Thread.currentThread().getContextClassLoader();

      try {
        Class<?> api = Class.forName(webService.endpointInterface(),
                                     false, loader);

        return api;
      } catch (Exception e) {
        throw ConfigException.create(e);
View Full Code Here

Examples of javax.jws.WebService

  private static JAXBContext _context = null;

  public static WSDLDefinitions parse(Class api)
    throws WebServiceException
  {
    WebService service = (WebService) api.getAnnotation(WebService.class);

    if (service == null) {
      if (log.isLoggable(Level.FINER))
        log.finer("No @WebService found on " + api);

      return null;
    }

    String wsdlLocation = null;

    if (! "".equals(service.wsdlLocation())) {
      wsdlLocation = service.wsdlLocation();
    }
    else if (! "".equals(service.endpointInterface())) {
      try {
        ClassLoader loader = api.getClassLoader();
        Class ei = loader.loadClass(service.endpointInterface());

        service = (WebService) api.getAnnotation(WebService.class);

        if (service == null) {
          if (log.isLoggable(Level.FINER))
            log.finer("No @WebService found on " + api);

          return null;
        }

        if (! "".equals(service.wsdlLocation()))
          wsdlLocation = service.wsdlLocation();
      }
      catch (ClassNotFoundException e) {
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.