Search in sources :

Example 1 with WebServiceClientAnnot

use of org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot in project axis-axis2-java-core by apache.

the class ClientDBCSupportEchoServiceImplWithSEI method testServiceClientWSDLLocationOverride.

/**
 * Create a ServiceDescription using a sparse composite that overrides the wsdlLocation on the
 * WebServiceClient annotation.  Validate the override only affects the wsdlLocation and not
 * the other annotations members.
 */
public void testServiceClientWSDLLocationOverride() {
    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 = 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));
    // The client annot we set as a sparse composite should be the same.
    assertSame(wsClientAnno, svcDescComposite.getSparseComposite(compositeKey).getWebServiceClientAnnot());
    // The WebServiceClient annot on the service desc should represent the wsdl override from the
    // sparse composite
    WebServiceClient wsClient = svcDescComposite.getWebServiceClientAnnot(compositeKey);
    assertEquals(overridenWsdlLocation, wsClient.wsdlLocation());
    // Make sure the non-overridden values still come from the service class annotation
    assertEquals("originalTNS", wsClient.targetNamespace());
    assertEquals("", wsClient.name());
}
Also used : DescriptionBuilderComposite(org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite) QName(javax.xml.namespace.QName) ServiceDescription(org.apache.axis2.jaxws.description.ServiceDescription) WebServiceClientAnnot(org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot) WebServiceClient(javax.xml.ws.WebServiceClient)

Example 2 with WebServiceClientAnnot

use of org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot in project axis-axis2-java-core by apache.

the class SparseAnnotServiceSubclass method testNoSparseAnnot.

public void testNoSparseAnnot() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    ServiceDescription svcDesc = DescriptionFactory.createServiceDescription(null, serviceQName, SparseAnnotServiceSubclass.class);
    assertNotNull(svcDesc);
    // A DBC will be created for us
    DescriptionBuilderComposite svcDescComposite = DescriptionTestUtils.getServiceDescriptionComposite(svcDesc);
    assertNotNull(svcDescComposite);
    WebServiceClient wsClient = svcDescComposite.getWebServiceClientAnnot();
    // There is no DBC Annot in this case; it is the class annotation but it should be
    // returned as an instance of a WebServiceClientAnnot
    assertTrue(wsClient instanceof WebServiceClientAnnot);
}
Also used : QName(javax.xml.namespace.QName) ServiceDescription(org.apache.axis2.jaxws.description.ServiceDescription) WebServiceClient(javax.xml.ws.WebServiceClient)

Example 3 with WebServiceClientAnnot

use of org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot in project axis-axis2-java-core by apache.

the class MetadataTestCachingClientContextFactory method testNoArgGeneratedServiceOverrideWsdlLocation.

/**
 * Generated service constructor() with a composite that specifies a wsdlLocation override
 */
public void testNoArgGeneratedServiceOverrideWsdlLocation() {
    DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
    WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, getWsdlLocation(overridenWsdl));
    composite.setWebServiceClientAnnot(wsClientAnno);
    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 was overriden in the composite
    // for this key, however the keyless composite should not have any overrides.
    WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
    assertNotNull(wsClient);
    assertEquals(originalWsdl, wsClient.wsdlLocation());
    assertEquals("originalTNS", wsClient.targetNamespace());
    assertEquals("", wsClient.name());
    WebServiceClient wsClientKeyed = dbcInServiceDesc.getWebServiceClientAnnot(serviceDelegate);
    assertNotSame(wsClient, wsClientKeyed);
    assertEquals(getWsdlLocation(overridenWsdl), wsClientKeyed.wsdlLocation());
    assertEquals("originalTNS", wsClientKeyed.targetNamespace());
    assertEquals("", wsClientKeyed.name());
    // WSDL override specified in the composite
    assertTrue("Wrong WSDL used", validatePort(service, overridenWsdl_portLocalPart));
}
Also used : DescriptionBuilderComposite(org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite) ServiceDescription(org.apache.axis2.jaxws.description.ServiceDescription) Service(javax.xml.ws.Service) WebServiceClientAnnot(org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot) WebServiceClient(javax.xml.ws.WebServiceClient)

Example 4 with WebServiceClientAnnot

use of org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot in project axis-axis2-java-core by apache.

the class MetadataTestCachingClientContextFactory method test2ArgGeneratedServiceOverrideWsdlLocation.

/**
 * Generated service constructor(URL, QName) with a composite that specifies a wsdlLocation override
 */
public void test2ArgGeneratedServiceOverrideWsdlLocation() {
    DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
    WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, getWsdlLocation(overridenWsdl));
    composite.setWebServiceClientAnnot(wsClientAnno);
    ServiceDelegate.setServiceMetadata(composite);
    Service service = new ClientMetadataGeneratedService(getWsdlURL(otherWsdl), new QName(namespaceURI, svcLocalPart));
    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 was overriden in the composite
    // for this key, however the keyless composite should not have any overrides.
    WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
    assertNotNull(wsClient);
    assertEquals(originalWsdl, wsClient.wsdlLocation());
    assertEquals("originalTNS", wsClient.targetNamespace());
    assertEquals("", wsClient.name());
    WebServiceClient wsClientKeyed = dbcInServiceDesc.getWebServiceClientAnnot(serviceDelegate);
    assertNotSame(wsClient, wsClientKeyed);
    assertEquals(getWsdlLocation(overridenWsdl), wsClientKeyed.wsdlLocation());
    assertEquals("originalTNS", wsClientKeyed.targetNamespace());
    assertEquals("", wsClientKeyed.name());
    // WSDL override specified in the composite
    assertTrue("Wrong WSDL used", validatePort(service, overridenWsdl_portLocalPart));
}
Also used : DescriptionBuilderComposite(org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite) QName(javax.xml.namespace.QName) ServiceDescription(org.apache.axis2.jaxws.description.ServiceDescription) Service(javax.xml.ws.Service) WebServiceClientAnnot(org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot) WebServiceClient(javax.xml.ws.WebServiceClient)

Example 5 with WebServiceClientAnnot

use of org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot in project axis-axis2-java-core by apache.

the class MetadataTestCachingClientContextFactory method test1ArgServiceOverrideWsdlLocation.

/**
 * Service.create(QName) with a composite that specifies a wsdlLocation override
 */
public void test1ArgServiceOverrideWsdlLocation() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
    WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, getWsdlLocation(overridenWsdl));
    composite.setWebServiceClientAnnot(wsClientAnno);
    // 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());
    // This is a generic Service with overrides, there will be WebServiceClient annotation
    WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
    assertNull(wsClient);
    wsClient = dbcInServiceDesc.getWebServiceClientAnnot(serviceDelegate);
    assertNotNull(wsClient);
    assertEquals(getWsdlLocation(overridenWsdl), wsClient.wsdlLocation());
    assertNull(wsClient.targetNamespace());
    assertNull(wsClient.name());
    // WSDL override specified in the composite
    assertTrue("Wrong WSDL used", validatePort(service, overridenWsdl_portLocalPart));
}
Also used : DescriptionBuilderComposite(org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite) QName(javax.xml.namespace.QName) ServiceDescription(org.apache.axis2.jaxws.description.ServiceDescription) Service(javax.xml.ws.Service) WebServiceClientAnnot(org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot) WebServiceClient(javax.xml.ws.WebServiceClient)

Aggregations

WebServiceClient (javax.xml.ws.WebServiceClient)10 ServiceDescription (org.apache.axis2.jaxws.description.ServiceDescription)10 DescriptionBuilderComposite (org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite)10 WebServiceClientAnnot (org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot)10 QName (javax.xml.namespace.QName)9 Service (javax.xml.ws.Service)9 WebServiceException (javax.xml.ws.WebServiceException)2 URL (java.net.URL)1