當前位置: 首頁>>代碼示例>>Java>>正文


Java WebServiceClient類代碼示例

本文整理匯總了Java中javax.xml.ws.WebServiceClient的典型用法代碼示例。如果您正苦於以下問題:Java WebServiceClient類的具體用法?Java WebServiceClient怎麽用?Java WebServiceClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WebServiceClient類屬於javax.xml.ws包,在下文中一共展示了WebServiceClient類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getWsdlURL

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
private URL getWsdlURL(final UnifiedServiceRefMetaData serviceRefMD, final Class<?> serviceClass)
{
   if (serviceRefMD.getWsdlLocation() == null)
   {
      final WebServiceClient webServiceClientAnnotation = serviceClass.getAnnotation(WebServiceClient.class);
      if (webServiceClientAnnotation != null)
      {
         // use the @WebServiceClien(wsdlLocation=...) if the service ref wsdl location returned at this time would be null
         if (webServiceClientAnnotation.wsdlLocation().length() > 0)
         {
            return serviceRefMD.getWsdlLocation(webServiceClientAnnotation.wsdlLocation());
         }
      }
   }

   return serviceRefMD.getWsdlLocation();
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:18,代碼來源:CXFServiceObjectFactoryJAXWS.java

示例2: getService

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
/**
 * Returns the remote service interface. 
 * @return service interface
 */
public I getService() throws Exception {
	try {  
	if (remoteService == null) { 
		WebServiceClient ann = serviceType.getAnnotation(WebServiceClient.class);			 	 
		URL remoteWsdl = new URL( getRemoteWSDLURL()); 
		service = serviceType.getConstructor(URL.class, QName.class).newInstance(remoteWsdl, new QName(ann.targetNamespace(), ann.name()));  
		remoteService = service.getPort(interfaceType);   
		if (handlers.size() > 0 ) {				
			BindingProvider bindProv = (BindingProvider) remoteService; 
			bindProv.getBinding().setHandlerChain(handlers); 
		}
	}
	} catch (WebServiceException ex) {
		throw new Exception ("Service connection fails.");
	} catch (NullPointerException e) {
		throw new Exception ("Review JaxWSClient configuration.");
	}
	return remoteService;
}
 
開發者ID:Appverse,項目名稱:appverse-server,代碼行數:24,代碼來源:AbstractWSClient.java

示例3: testOriginalGetPort

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
/**
 * Test the getPort functionality without any composite specified.
 */
public void testOriginalGetPort() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    URL wsdlUrl = ClientMetadataTest.getWsdlURL(otherWsdl);
    Service service = Service.create(wsdlUrl, serviceQName);
    assertNotNull(service);
    ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
    assertNotNull(serviceDelegate);
    ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
    assertNotNull(serviceDesc);
    DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
    assertNotNull(dbcInServiceDesc);
    assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
    // Since this is a generic Service with no overrides, there will be no WebServiceClient annotation
    WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
    assertNull(wsClient);

    // WSDL was specified on the create, so make sure the right one was used by checking the ports
    assertTrue("Wrong WSDL used", ClientMetadataTest.validatePort(service, otherWsdl_portLocalPart));
    
    QName portQN = new QName(namespaceURI, otherWsdl_portLocalPart);
    ClientMetadataPortSEI port = service.getPort(portQN, ClientMetadataPortSEI.class);
    assertNotNull(port);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:27,代碼來源:ClientMetadataPortTest.java

示例4: test1ArgServiceWithoutComposite

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
/**
 * Test Service.create(QName) with no composite specified 
 */
public void test1ArgServiceWithoutComposite() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    Service service = Service.create(serviceQName);
    assertNotNull(service);
    ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
    assertNotNull(serviceDelegate);
    ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
    assertNotNull(serviceDesc);
    DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
    assertNotNull(dbcInServiceDesc);
    assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
    // Since this is a generic Service with no overrides, there will be no WebServiceClient annotation
    WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
    assertNull(wsClient);
    
    // No WSDL should have been used, so no Ports should be found
    assertTrue("Wrong WSDL used", validatePort(service, null));
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:22,代碼來源:ClientMetadataTest.java

示例5: test2ArgServiceWithoutComposite

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
/**
 * Service.create(URL, QName) with no composite specified
 */
public void test2ArgServiceWithoutComposite() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    URL wsdlUrl = getWsdlURL(otherWsdl);
    Service service = Service.create(wsdlUrl, serviceQName);
    assertNotNull(service);
    ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
    assertNotNull(serviceDelegate);
    ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
    assertNotNull(serviceDesc);
    DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
    assertNotNull(dbcInServiceDesc);
    assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
    // Since this is a generic Service with no overrides, there will be no WebServiceClient annotation
    WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
    assertNull(wsClient);

    // WSDL was specified on the create, so make sure the right one was used by checking the ports
    assertTrue("Wrong WSDL used", validatePort(service, otherWsdl_portLocalPart));
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:23,代碼來源:ClientMetadataTest.java

示例6: test2ArgServiceWithComposite

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
/**
 * Service.create(URL, QName) with a composite specified but no override in the composite 
 */
public void test2ArgServiceWithComposite() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);

    DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
    URL wsdlUrl = getWsdlURL(otherWsdl);
    // Use the proprietary SPI to create a service with additional metadata specified
    ServiceDelegate.setServiceMetadata(composite);
    Service service = Service.create(wsdlUrl, serviceQName);
    assertNotNull(service);
    // Verify that the composite has been reset so that it would not affect the next Service
    assertNull(ServiceDelegate.getServiceMetadata());
    ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
    assertNotNull(serviceDelegate);
    ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
    assertNotNull(serviceDesc);
    DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
    assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
    assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
    // Since this is a generic Service with no overrides, there will be no WebServiceClient annotation
    WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
    assertNull(wsClient);
    
    // WSDL was specified on the create, so make sure the right one was used by checking the ports
    assertTrue("Wrong WSDL used", validatePort(service, otherWsdl_portLocalPart));
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:29,代碼來源:ClientMetadataTest.java

示例7: testNoArgGeneratedService

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
/**
 * Generated service constructor() with no composite specified 
 */
public void testNoArgGeneratedService() {
    Service service = new ClientMetadataGeneratedService();
    assertNotNull(service);

    ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
    assertNotNull(serviceDelegate);
    ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
    assertNotNull(serviceDesc);
    DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
    assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
    // There is WebServiceClient on the generated Service
    WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
    assertNotNull(wsClient);
    assertEquals(originalWsdl, wsClient.wsdlLocation());
    assertEquals("originalTNS", wsClient.targetNamespace());
    assertEquals("", wsClient.name());
    
    // WSDL not specified, so generated Service should use the annotation value
    assertTrue("Wrong WSDL Used", validatePort(service, originalWsdl_portLocalPart));
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:ClientMetadataTest.java

示例8: test2ArgGeneratedService

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
/**
 * Generated service constructor(URL, QName) with no composite specified 
 */
public void test2ArgGeneratedService() {
    
    Service service = new ClientMetadataGeneratedService(getWsdlURL(otherWsdl), 
                                                          new QName(namespaceURI, svcLocalPart));
    assertNotNull(service);

    ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
    assertNotNull(serviceDelegate);
    ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
    assertNotNull(serviceDesc);
    DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
    assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
    // There is WebServiceClient on the generated Service
    WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
    assertNotNull(wsClient);

    assertEquals(originalWsdl, wsClient.wsdlLocation());
    assertEquals("originalTNS", wsClient.targetNamespace());
    assertEquals("", wsClient.name());

    // WSDL was specified on the generated Service constructor, 
    // so make sure the right one was used by checking the ports
    assertTrue("Wrong WSDL used", validatePort(service, otherWsdl_portLocalPart));
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:28,代碼來源:ClientMetadataTest.java

示例9: testClientServiceClassComposite

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
/**
 * Create a ServiceDescription with a composite.  Nothing in the composite is overriden; validate
 * the values from the annotions in the Service class.
 */
public void testClientServiceClassComposite() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
    Object compositeKey = "CompositeKey";
    ServiceDescription svcDesc = 
        new ServiceDescriptionImpl(null, serviceQName, 
                                   ClientDBCSupportServiceSubclass.class, 
                                   composite, compositeKey);
    assertNotNull(svcDesc);
    ServiceDescriptionImpl svcDescImpl = (ServiceDescriptionImpl) svcDesc;
    DescriptionBuilderComposite svcDescComposite = svcDescImpl.getDescriptionBuilderComposite();
    assertNotNull(svcDescComposite);
    assertNotSame(composite, svcDescComposite);
    assertSame(composite, svcDescComposite.getSparseComposite(compositeKey));
    
    WebServiceClient wsClient = svcDescComposite.getWebServiceClientAnnot();
    assertNotNull(wsClient);
    assertEquals("originalWsdlLocation", wsClient.wsdlLocation());
    assertEquals("originalTNS", wsClient.targetNamespace());
    // We're testing the composite, not the metadata layer, so none of the defaulting logic
    // is exercised.
    assertEquals("", wsClient.name());
    
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:29,代碼來源:ClientDBCSupportTests.java

示例10: testAssociatedClass

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
public void testAssociatedClass() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    // Create a composite with a WebServiceClient override of the WSDL location.
    DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
    String overridenWsdlLocation = DescriptionTestUtils.getWSDLLocation("ClientEndpointMetadata.wsdl");
    WebServiceClientAnnot wsClientAnno = 
        WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, overridenWsdlLocation);
    composite.setWebServiceClientAnnot(wsClientAnno);
    Object compositeKey = "CompositeKey";
    ServiceDescription svcDesc = 
        DescriptionFactory.createServiceDescription(null, serviceQName, 
                                                    SparseAnnotServiceSubclass.class, 
                                                    composite, compositeKey);
    assertNotNull(svcDesc);
    DescriptionBuilderComposite svcDescComposite = DescriptionTestUtils.getServiceDescriptionComposite(svcDesc);
    assertNotNull(svcDescComposite);
    assertNotSame(composite, svcDescComposite);
    assertSame(SparseAnnotServiceSubclass.class, svcDescComposite.getCorrespondingClass());
    assertSame(composite, svcDescComposite.getSparseComposite(compositeKey));
    WebServiceClient wsClient = svcDescComposite.getWebServiceClientAnnot();
    assertTrue(wsClient instanceof WebServiceClientAnnot);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:23,代碼來源:SparseAnnotTests.java

示例11: getClientService

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
/**
    * Gets a client service instance of the given name.
    * The name must be one of the names returned by {@link #getSupportedServices()}. The use of this method is
    * strongly encouraged, as it uses the WSDLs and XML schemas bundled with this class. This leads to lower load
    * times.<br/>
    * The service client is initialized with the values from the WSDL. In order to set other endpoints, use the other
    * {@code getClientService} functions.
    *
    * @param serviceName Name of the service. Must be one of the names returned by {@link #getSupportedServices()}.
    * @return Webservice client initialized with the settings from the WSDL.
    * @throws NoSuchMethodException In case there is no suitable constructor or {@code getPort()} method in the service
    *   class.
    * @throws InstantiationException In case the constructor call failed.
    * @throws IllegalAccessException In case the constructor call or the {@code getPort()} method failed.
    * @throws InvocationTargetException In case the constructor call or the {@code getPort()} method failed.
    * @throws ClassNotFoundException In case no such service is registered in this loader.
    * @see #getClientService(java.lang.String, java.lang.String)
    * @see #getClientService(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
    */
   public static Object getClientService(@Nonnull String serviceName)
    throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException,
           ClassNotFoundException {
// the relevant information to create a service is extracted from the service instance
// get serviceloader instance
Class<Service> loaderClass = loadClass(serviceName);
WebServiceClient clientAnnotation = getClientAnnotation(loaderClass);
Constructor<Service> constructor = loaderClass.getConstructor(URL.class, QName.class);
QName serviceQname = new QName(clientAnnotation.targetNamespace(), clientAnnotation.name());
Service serviceLoaderInst = constructor.newInstance(getWSDL(), serviceQname);
//Constructor constructor = loaderClass.getConstructor();
//Service serviceLoaderInst = (Service) constructor.newInstance();

// get portmethod and call it to get actual service
String portName = servicePorts.get(serviceName);
Method portMethod = serviceLoaderInst.getClass().getMethod("get" + portName, WebServiceFeature[].class);
//WebServiceFeature validator = (WebServiceFeature) inst.loadClass("com.sun.xml.internal.ws.developer.SchemaValidationFeature").getConstructor().newInstance();
//Object serviceInst = portMethod.invoke(serviceLoaderInst, new Object[]{ new WebServiceFeature[] {validator} });
Object serviceInst = portMethod.invoke(serviceLoaderInst, new Object[]{ new WebServiceFeature[] {} });

return serviceInst;
   }
 
開發者ID:credentials,項目名稱:irma_future_id,代碼行數:42,代碼來源:WSClassLoader.java

示例12: SCAnnotations

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
SCAnnotations(final Class<?> sc) {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        @Override
        public Void run() {
            WebServiceClient wsc =sc.getAnnotation(WebServiceClient.class);
            if(wsc==null) {
                throw new WebServiceException("Service Interface Annotations required, exiting...");
            }

            String tns = wsc.targetNamespace();
            try {
                JAXWSUtils.getFileOrURL(wsc.wsdlLocation());
            } catch (IOException e) {
                // TODO: report a reasonable error message
                throw new WebServiceException(e);
            }

            for (Method method : sc.getDeclaredMethods()) {
                WebEndpoint webEndpoint = method.getAnnotation(WebEndpoint.class);
                if (webEndpoint != null) {
                    String endpointName = webEndpoint.name();
                    QName portQName = new QName(tns, endpointName);
                    portQNames.add(portQName);
                }
                Class<?> seiClazz = method.getReturnType();
                if (seiClazz!=void.class) {
                    classes.add(seiClazz);
                }
            }

            return null;
        }
    });
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:35,代碼來源:SCAnnotations.java

示例13: getServiceQName

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
private QName getServiceQName(final UnifiedServiceRefMetaData serviceRefMD, final Class<?> serviceClass)
{
   QName retVal = serviceRefMD.getServiceQName();

   if (retVal == null)
   {
      final WebServiceClient webServiceClientAnnotation = serviceClass.getAnnotation(WebServiceClient.class);
      if (webServiceClientAnnotation != null)
      {
         retVal = new QName(webServiceClientAnnotation.targetNamespace(), webServiceClientAnnotation.name());
      }
   }

   return retVal;
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:16,代碼來源:CXFServiceObjectFactoryJAXWS.java

示例14: test1ArgServiceWithComposite

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
/**
 * Service.create(QName) with a composite specified but no override in the composite 
 */
public void test1ArgServiceWithComposite() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
    assertNull(ServiceDelegate.getServiceMetadata());
    // Use the proprietary SPI to create a service with additional metadata specified
    ServiceDelegate.setServiceMetadata(composite);
    
    Service service = Service.create(serviceQName);
    assertNotNull(service);
    
    // Verify that the composite has been reset so that it would not affect the next Service
    assertNull(ServiceDelegate.getServiceMetadata());
    ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
    assertNotNull(serviceDelegate);
    ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
    assertNotNull(serviceDesc);
    DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
    assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
    assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
    // Since this is a generic Service with no overrides, there will be no WebServiceClient annotation
    WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
    assertNull(wsClient);
    
    // No WSDL should have been used, so no Ports should be found
    assertTrue("Wrong WSDL used", validatePort(service, null));

}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:31,代碼來源:ClientMetadataTest.java

示例15: testNoArgGeneratedServiceWithComposite

import javax.xml.ws.WebServiceClient; //導入依賴的package包/類
/**
 * Generated service constructor() with composite specified but no override in composite 
 */
public void testNoArgGeneratedServiceWithComposite() {
    DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
    ServiceDelegate.setServiceMetadata(composite);

    Service service = new ClientMetadataGeneratedService();
    assertNotNull(service);
    assertNull(ServiceDelegate.getServiceMetadata());
    
    ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
    assertNotNull(serviceDelegate);
    ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
    assertNotNull(serviceDesc);
    DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
    assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
    assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
    // There is WebServiceClient on the generated Service and it wasn't overriden in the composite
    WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
    assertNotNull(wsClient);
    assertEquals(originalWsdl, wsClient.wsdlLocation());
    assertEquals("originalTNS", wsClient.targetNamespace());
    assertEquals("", wsClient.name());
    
    // No WSDL override specified in the composite, so generated Service should use the annotation value
    assertTrue("Wrong WSDL Used", validatePort(service, originalWsdl_portLocalPart));

}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:30,代碼來源:ClientMetadataTest.java


注:本文中的javax.xml.ws.WebServiceClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。