Search in sources :

Example 1 with WSDLLocation

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

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

the class OperationDescriptionImplTests method testDetermineOperationQName.

public void testDetermineOperationQName() {
    String wsdlRelativeLocation = "test-resources/wsdl/";
    String wsdlFileName = "BindingNamespaceDefaults.wsdl";
    String targetNamespace = "http://nonanonymous.complextype.test.org";
    String wsdlLocation = wsdlRelativeLocation + wsdlFileName;
    // Build up a DBC, including the WSDL Definition and the annotation information for
    // the impl class.
    DescriptionBuilderComposite dbc = new DescriptionBuilderComposite();
    URL wsdlURL = DescriptionTestUtils.getWSDLURL(wsdlFileName);
    Definition wsdlDefn = DescriptionTestUtils.createWSDLDefinition(wsdlURL);
    assertNotNull(wsdlDefn);
    WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
    assertNotNull(webServiceAnnot);
    webServiceAnnot.setWsdlLocation(wsdlLocation);
    webServiceAnnot.setTargetNamespace(targetNamespace);
    webServiceAnnot.setServiceName("EchoMessageService");
    webServiceAnnot.setPortName("EchoMessagePort");
    MethodDescriptionComposite mdc = new MethodDescriptionComposite();
    mdc.setMethodName("echoMessage");
    mdc.setReturnType("java.lang.String");
    ParameterDescriptionComposite pdc1 = new ParameterDescriptionComposite();
    pdc1.setParameterType("java.lang.String");
    mdc.addParameterDescriptionComposite(pdc1);
    dbc.addMethodDescriptionComposite(mdc);
    dbc.setWebServiceAnnot(webServiceAnnot);
    dbc.setClassName(BindingNSImpl.class.getName());
    dbc.setWsdlDefinition(wsdlDefn);
    dbc.setwsdlURL(wsdlURL);
    HashMap<String, DescriptionBuilderComposite> dbcMap = new HashMap<String, DescriptionBuilderComposite>();
    dbcMap.put(dbc.getClassName(), dbc);
    List<ServiceDescription> serviceDescList = DescriptionFactory.createServiceDescriptionFromDBCMap(dbcMap);
    ServiceDescription sd = serviceDescList.get(0);
    EndpointInterfaceDescription eid = new EndpointInterfaceDescriptionImpl(dbc, new EndpointDescriptionImpl(null, new QName(targetNamespace, "EchoMessagePort"), (ServiceDescriptionImpl) sd));
    assertEquals(new QName(targetNamespace, "echoMessage"), OperationDescriptionImpl.determineOperationQName(eid, mdc));
}
Also used : HashMap(java.util.HashMap) ServiceDescription(org.apache.axis2.jaxws.description.ServiceDescription) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) MethodDescriptionComposite(org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite) URL(java.net.URL) ParameterDescriptionComposite(org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite) DescriptionBuilderComposite(org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite) WebServiceAnnot(org.apache.axis2.jaxws.description.builder.WebServiceAnnot) EndpointInterfaceDescription(org.apache.axis2.jaxws.description.EndpointInterfaceDescription)

Example 3 with WSDLLocation

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

the class EndpointReferenceHelper method getWSDLLocationMetadata.

/**
 * Retrieves the wsdli:wsdlLocation attribute from an EPR.
 *
 * @param epr the EPR to retrieve the attribute from
 * @param addressingNamespace the WS-Addressing namespace associated with
 * the EPR.
 * @return an instance of <code>WSDLLocation</code>. The return value is
 * never <code>null</code>.
 * @throws AxisFault
 */
public static WSDLLocation getWSDLLocationMetadata(EndpointReference epr, String addressingNamespace) throws AxisFault {
    WSDLLocation wsdlLocation = new WSDLLocation();
    List attributes = null;
    if (AddressingConstants.Submission.WSA_NAMESPACE.equals(addressingNamespace))
        attributes = epr.getAttributes();
    else
        attributes = epr.getMetadataAttributes();
    if (attributes != null) {
        // Retrieve the wsdl location.
        for (int i = 0, size = attributes.size(); i < size; i++) {
            OMAttribute omAttribute = (OMAttribute) attributes.get(i);
            if (WSDLLocation.isWSDLLocationAttribute(omAttribute)) {
                wsdlLocation.fromOM(omAttribute);
                break;
            }
        }
    }
    return wsdlLocation;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) WSDLLocation(org.apache.axis2.addressing.metadata.WSDLLocation) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 4 with WSDLLocation

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

the class WSDLLocation method fromOM.

/**
 * Convenience method for converting an OMAttribute to an instance of either of these types.
 * <p>
 * &lt;... xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance" wsdli:wsdlLocation="targetNamespace wsdlURL" ...&gt
 * </p>
 * <p>
 * &lt;... xmlns:wsdli="http://www.w3.org/ns/wsdl-instance" wsdli:wsdlLocation="targetNamespace wsdlURL" ...&gt
 * </p>
 * @param omAttribute the <code>OMAttribute</code> that holds the wsdl location.
 * @throws AxisFault
 */
public void fromOM(OMAttribute omAttribute) throws AxisFault {
    QName qname = omAttribute.getQName();
    if (WSDLI.equals(qname) || FINAL_WSDLI.equals(qname)) {
        String value = omAttribute.getAttributeValue().trim();
        String[] values = value.split("\\s", 2);
        // give us the correct number of elements.
        if (values.length != 2)
            return;
        targetNamespace = values[0];
        wsdlURL = values[1];
        if (log.isDebugEnabled()) {
            log.debug("fromOM: Extracted WSDLLocation targetNamespace = " + targetNamespace + " and wsdlURL = " + wsdlURL + " from an OMAttribute with QName = " + qname);
        }
    } else {
        throw new AxisFault("Unrecognized element.");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) QName(javax.xml.namespace.QName)

Example 5 with WSDLLocation

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

the class EndpointReferenceHelperTest method testSetAndGetWSDLLocationMetadataForFinalSpecEPR.

public void testSetAndGetWSDLLocationMetadataForFinalSpecEPR() throws Exception {
    String address = "http://ws.apache.org/axis2";
    String targetNamespace = "targetNamespace";
    String location = "wsdlLocation";
    EndpointReference epr = new EndpointReference(address);
    OMFactory omf = OMAbstractFactory.getOMFactory();
    // Uses final WSDLI namespace on wsdlLocation attribute
    EndpointReferenceHelper.setWSDLLocationMetadata(omf, epr, AddressingConstants.Final.WSA_NAMESPACE, new WSDLLocation(targetNamespace, location));
    WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(epr, AddressingConstants.Final.WSA_NAMESPACE);
    assertEquals(wsdlLocation.getTargetNamespace(), targetNamespace);
    assertEquals(wsdlLocation.getLocation(), location);
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) WSDLLocation(org.apache.axis2.addressing.metadata.WSDLLocation)

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