Search in sources :

Example 6 with WSDLLocation

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

the class EndpointReferenceHelperTest method testGetWSDLLocationMetadataForFinalSpecEPRWithOldWsdliNamespace.

public void testGetWSDLLocationMetadataForFinalSpecEPRWithOldWsdliNamespace() throws Exception {
    String address = "http://ws.apache.org/axis2";
    String targetNamespace = "targetNamespace";
    String location = "wsdlLocation";
    EndpointReference epr = new EndpointReference(address);
    // Uses old candidate spec WSDLI namespace on wsdlLocation attribute
    OMFactory omf = OMAbstractFactory.getOMFactory();
    String value = new StringBuffer(targetNamespace).append(" ").append(location).toString();
    QName OLD_WSDLI = new QName("http://www.w3.org/2006/01/wsdl-instance", "wsdlLocation", "wsdli");
    OMNamespace wsdliNs = omf.createOMNamespace(OLD_WSDLI.getNamespaceURI(), OLD_WSDLI.getPrefix());
    OMAttribute attribute = omf.createOMAttribute(OLD_WSDLI.getLocalPart(), wsdliNs, value);
    ArrayList list = new ArrayList();
    list.add(attribute);
    epr.setMetadataAttributes(list);
    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) OMNamespace(org.apache.axiom.om.OMNamespace) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) WSDLLocation(org.apache.axis2.addressing.metadata.WSDLLocation) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 7 with WSDLLocation

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

the class EndpointReferenceHelperTest method testSetAndGetWSDLLocationMetadataForSubmissionSpecEPR.

public void testSetAndGetWSDLLocationMetadataForSubmissionSpecEPR() 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.Submission.WSA_NAMESPACE, new WSDLLocation(targetNamespace, location));
    WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(epr, AddressingConstants.Submission.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)

Example 8 with WSDLLocation

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

the class PackageSetBuilder method getPackagesFromSchema.

/**
 * Walks the schemas of the serviceDesc's wsdl (or generated wsdl) to determine the list of
 * packages. This is the preferred algorithm for discovering the package set.
 *
 * @param serviceDesc ServiceDescription
 * @return Set of Packages
 */
public static TreeSet<String> getPackagesFromSchema(ServiceDescription serviceDesc) {
    if (log.isDebugEnabled()) {
        log.debug("start getPackagesFromSchema");
        log.debug("ServiceDescription = " + serviceDesc.toString());
    }
    TreeSet<String> set = new TreeSet<String>();
    // If we are on client side we will get wsdl definition from ServiceDescription. If we are on server side we will have to
    // read wsdlLocation from @WebService Annotation.
    ServiceDescriptionWSDL sdw = (ServiceDescriptionWSDL) serviceDesc;
    Definition wsdlDefinition = sdw.getWSDLDefinition();
    Collection<EndpointDescription> endpointDescs = serviceDesc.getEndpointDescriptions_AsCollection();
    if (endpointDescs != null) {
        for (EndpointDescription ed : endpointDescs) {
            if (wsdlDefinition == null) {
                // Let see if we can get wsdl definition from endpoint @WebService annotation.
                if (ed instanceof EndpointDescriptionJava) {
                    String wsdlLocation = ((EndpointDescriptionJava) ed).getAnnoWebServiceWSDLLocation();
                    wsdlDefinition = getWSDLDefinition(wsdlLocation);
                }
            }
            // on client side) or we got it from the @WebService annotation (which means we are running this code on server side)
            if (wsdlDefinition != null) {
                SchemaReader sr = new SchemaReaderImpl();
                try {
                    Set<String> pkgSet = sr.readPackagesFromSchema(wsdlDefinition);
                    set.addAll(pkgSet);
                } catch (SchemaReaderException e) {
                    throw ExceptionFactory.makeWebServiceException(e);
                }
            }
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("end getPackagesFromSchema");
    }
    return set;
}
Also used : SchemaReaderImpl(org.apache.axis2.jaxws.wsdl.impl.SchemaReaderImpl) SchemaReader(org.apache.axis2.jaxws.wsdl.SchemaReader) ServiceDescriptionWSDL(org.apache.axis2.jaxws.description.ServiceDescriptionWSDL) SchemaReaderException(org.apache.axis2.jaxws.wsdl.SchemaReaderException) TreeSet(java.util.TreeSet) EndpointDescriptionJava(org.apache.axis2.jaxws.description.EndpointDescriptionJava) Definition(javax.wsdl.Definition) EndpointDescription(org.apache.axis2.jaxws.description.EndpointDescription)

Example 9 with WSDLLocation

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

the class Provider method getPort.

@Override
public <T> T getPort(EndpointReference jaxwsEPR, Class<T> sei, WebServiceFeature... features) {
    if (jaxwsEPR == null) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchNoEndpointReference2"));
    }
    if (sei == null) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("getPortInvalidSEI", jaxwsEPR.toString(), "null"));
    }
    org.apache.axis2.addressing.EndpointReference axis2EPR = EndpointReferenceUtils.createAxis2EndpointReference("");
    String addressingNamespace = null;
    try {
        addressingNamespace = EndpointReferenceUtils.convertToAxis2(axis2EPR, jaxwsEPR);
    } catch (Exception e) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("invalidEndpointReference", e.toString()));
    }
    org.apache.axis2.jaxws.spi.ServiceDelegate serviceDelegate = null;
    try {
        ServiceName serviceName = EndpointReferenceHelper.getServiceNameMetadata(axis2EPR, addressingNamespace);
        WSDLLocation wsdlLocation = EndpointReferenceHelper.getWSDLLocationMetadata(axis2EPR, addressingNamespace);
        URL wsdlLocationURL = null;
        if (wsdlLocation.getLocation() != null) {
            wsdlLocationURL = new URL(wsdlLocation.getLocation());
            if (log.isDebugEnabled()) {
                log.debug("getPort: Using EPR wsdlLocationURL = " + wsdlLocationURL);
            }
        } else {
            wsdlLocationURL = new URL(axis2EPR.getAddress() + "?wsdl");
            if (log.isDebugEnabled()) {
                log.debug("getPort: Using default wsdlLocationURL = " + wsdlLocationURL);
            }
        }
        serviceDelegate = new org.apache.axis2.jaxws.spi.ServiceDelegate(wsdlLocationURL, serviceName.getName(), Service.class);
    } catch (Exception e) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("endpointUpdateError"), e);
    }
    return serviceDelegate.getPort(axis2EPR, addressingNamespace, sei, features);
}
Also used : Service(javax.xml.ws.Service) URL(java.net.URL) ServiceName(org.apache.axis2.addressing.metadata.ServiceName) WSDLLocation(org.apache.axis2.addressing.metadata.WSDLLocation)

Example 10 with WSDLLocation

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

the class GorillaDLWProxyTests method getProxy.

/**
 * Utility method to get the proxy
 * @return GorillaInterface proxy
 * @throws MalformedURLException
 */
public GorillaInterface getProxy() throws Exception {
    File wsdl = new File(wsdlLocation);
    URL wsdlUrl = wsdl.toURI().toURL();
    Service service = Service.create(null, serviceName);
    Object proxy = service.getPort(portName, GorillaInterface.class);
    BindingProvider p = (BindingProvider) proxy;
    p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, server.getEndpoint("GorillaService.GorillaProxyImplPort"));
    return (GorillaInterface) proxy;
}
Also used : GorillaInterface(org.apache.axis2.jaxws.proxy.gorilla_dlw.sei.GorillaInterface) Service(javax.xml.ws.Service) BindingProvider(javax.xml.ws.BindingProvider) File(java.io.File) URL(java.net.URL)

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