Search in sources :

Example 26 with WSDLLocation

use of org.apache.axis2.addressing.metadata.WSDLLocation in project axis-axis2-java-core by apache.

the class WSDL11ToAxisServiceBuilderTest method testVersion.

public void testVersion() {
    XMLUnit.setIgnoreWhitespace(true);
    File testResourceFile = new File(wsdlLocation);
    try {
        WSDL11ToAllAxisServicesBuilder builder = new WSDL11ToAllAxisServicesBuilder(new FileInputStream(testResourceFile));
        AxisService axisService = builder.populateService();
        ConfigurationContext configContext = ConfigurationContextFactory.createDefaultConfigurationContext();
        AxisConfiguration axisConfig = configContext.getAxisConfiguration();
        axisConfig.addService(axisService);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        axisService.printWSDL(baos);
        assertXMLEqual(new FileReader(testResourceFile), new StringReader(new String(baos.toByteArray())));
    } catch (Exception e) {
        System.out.println("Error in WSDL : " + testResourceFile.getName());
        System.out.println("Exception: " + e.toString());
        fail("Caught exception " + e.toString());
    } finally {
        XMLUnit.setIgnoreWhitespace(false);
    }
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) WSDL11ToAllAxisServicesBuilder(org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder) AxisService(org.apache.axis2.description.AxisService) StringReader(java.io.StringReader) FileReader(java.io.FileReader) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 27 with WSDLLocation

use of org.apache.axis2.addressing.metadata.WSDLLocation 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 28 with WSDLLocation

use of org.apache.axis2.addressing.metadata.WSDLLocation 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 29 with WSDLLocation

use of org.apache.axis2.addressing.metadata.WSDLLocation 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)

Example 30 with WSDLLocation

use of org.apache.axis2.addressing.metadata.WSDLLocation in project axis-axis2-java-core by apache.

the class MetadataTestCachingClientContextFactory method test2ArgGeneratedServiceOverrideTNS.

/**
 * Generated service constructor(URL, QName) with a composite that specifies a
 * target Namespace override.  Most of the other tests are based on wsdlLocation since
 * that is what JSR-109 DDs override.  This test verifies that other members can also
 * be override.
 */
public void test2ArgGeneratedServiceOverrideTNS() {
    DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
    WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, "overrideTNS", 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("overrideTNS", 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)

Aggregations

URL (java.net.URL)38 DescriptionBuilderComposite (org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite)27 File (java.io.File)23 Definition (javax.wsdl.Definition)21 Service (javax.xml.ws.Service)18 HashMap (java.util.HashMap)15 QName (javax.xml.namespace.QName)15 AxisService (org.apache.axis2.description.AxisService)14 WebServiceAnnot (org.apache.axis2.jaxws.description.builder.WebServiceAnnot)14 ServiceDescription (org.apache.axis2.jaxws.description.ServiceDescription)13 WSDL4JWrapper (org.apache.axis2.jaxws.util.WSDL4JWrapper)13 MethodDescriptionComposite (org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite)12 ParameterDescriptionComposite (org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite)12 BindingProvider (javax.xml.ws.BindingProvider)10 Test (org.junit.Test)10 WebServiceClientAnnot (org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot)8 WebServiceClient (javax.xml.ws.WebServiceClient)7 DocLitWrappedProxy (org.apache.axis2.jaxws.proxy.doclitwrapped.DocLitWrappedProxy)7 ProxyDocLitWrappedService (org.apache.axis2.jaxws.proxy.doclitwrapped.ProxyDocLitWrappedService)7 WSDLLocation (org.apache.axis2.addressing.metadata.WSDLLocation)6