Search in sources :

Example 66 with WSDLLocation

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

the class PackageSetBuilder method getWSDLDefinition.

private static Definition getWSDLDefinition(String wsdlLoc) {
    Definition wsdlDefinition = null;
    final String wsdlLocation = wsdlLoc;
    if (wsdlLocation != null && wsdlLocation.trim().length() > 0) {
        try {
            wsdlDefinition = (Definition) AccessController.doPrivileged(new PrivilegedExceptionAction() {

                public Object run() throws MalformedURLException, IOException, WSDLException {
                    String baseDir = new File(System.getProperty("basedir", ".")).getCanonicalPath();
                    String wsdlLocationPath = new File(baseDir + File.separator + wsdlLocation).getAbsolutePath();
                    File file = new File(wsdlLocationPath);
                    URL url = file.toURI().toURL();
                    if (log.isDebugEnabled()) {
                        log.debug("Reading WSDL from URL:" + url.toString());
                    }
                    // This is a temporary wsdl and we use it to dig into the schemas,
                    // Thus the memory limit is set to false.  It will be discarded after it is used
                    // by the PackageSetBuilder implementation.
                    WSDLWrapper wsdlWrapper = new WSDL4JWrapper(url, false, 0);
                    return wsdlWrapper.getDefinition();
                }
            });
        } catch (PrivilegedActionException e) {
            // Swallow and continue
            if (log.isDebugEnabled()) {
                log.debug("Exception getting wsdlLocation: " + e.getException());
            }
        }
    }
    return wsdlDefinition;
}
Also used : MalformedURLException(java.net.MalformedURLException) WSDLException(javax.wsdl.WSDLException) WSDL4JWrapper(org.apache.axis2.jaxws.util.WSDL4JWrapper) PrivilegedActionException(java.security.PrivilegedActionException) Definition(javax.wsdl.Definition) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) IOException(java.io.IOException) File(java.io.File) URL(java.net.URL) WSDLWrapper(org.apache.axis2.jaxws.util.WSDLWrapper)

Example 67 with WSDLLocation

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

the class BindingProvider method getEndpointReference.

/*
     *  (non-Javadoc)
     * @see javax.xml.ws.BindingProvider#getEndpointReference(java.lang.Class)
     */
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
    EndpointReference jaxwsEPR = null;
    String addressingNamespace = EndpointReferenceUtils.getAddressingNamespace(clazz);
    try {
        org.apache.axis2.addressing.EndpointReference epr = binding.getAxis2EndpointReference();
        if (epr == null) {
            String address = (String) requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
            if (address == null)
                address = endpointDesc.getEndpointAddress();
            QName service = endpointDesc.getServiceQName();
            QName port = endpointDesc.getPortQName();
            // let the webcontainer redirect us to the real WSDL URL; it knows where it is
            String wsdlLocation = "?wsdl";
            epr = EndpointReferenceUtils.createAxis2EndpointReference(address, service, port, wsdlLocation, addressingNamespace);
            // Add reference parameters from WSDL to the EPR
            AxisService axisService = endpointDesc.getAxisService();
            if (axisService != null) {
                AxisEndpoint axisEndpoint = axisService.getEndpoint(axisService.getEndpointName());
                if (axisEndpoint != null) {
                    ArrayList referenceParameters = (ArrayList) axisEndpoint.getParameterValue(AddressingConstants.REFERENCE_PARAMETER_PARAMETER);
                    if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                        log.trace("getEndpointReference: Adding reference parameters to EPR from WSDL: axisService = " + axisService + ", axisEndpoint = " + axisEndpoint.getName() + ", referenceParameters = " + referenceParameters);
                    }
                    if (referenceParameters != null) {
                        Iterator iterator = referenceParameters.iterator();
                        HashMap<QName, OMElement> refParamMap = new HashMap<QName, OMElement>();
                        while (iterator.hasNext()) {
                            OMElement omElement = (OMElement) iterator.next();
                            refParamMap.put(omElement.getQName(), omElement);
                        }
                        epr.setReferenceParameters(refParamMap);
                    }
                }
            }
        } else if (!addressingNamespace.equals(binding.getAddressingNamespace())) {
            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("bindingProviderErr1", binding.getAddressingNamespace(), addressingNamespace));
        }
        jaxwsEPR = EndpointReferenceUtils.convertFromAxis2(epr, addressingNamespace);
    } catch (UnsupportedOperationException e) {
        throw e;
    } catch (WebServiceException e) {
        throw e;
    } catch (Exception e) {
        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("endpointRefConstructionFailure3", e.toString()));
    }
    return clazz.cast(jaxwsEPR);
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) AxisService(org.apache.axis2.description.AxisService) ArrayList(java.util.ArrayList) OMElement(org.apache.axiom.om.OMElement) WebServiceException(javax.xml.ws.WebServiceException) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Iterator(java.util.Iterator) AxisEndpoint(org.apache.axis2.description.AxisEndpoint)

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