Search in sources :

Example 1 with SOAPBindingExtensions

use of org.apache.woden.wsdl20.extensions.soap.SOAPBindingExtensions in project axis-axis2-java-core by apache.

the class WSDL20ToAxisServiceBuilder method processSOAPBindingExtention.

private void processSOAPBindingExtention(Binding binding, AxisBinding axisBinding, Interface serviceInterface) throws AxisFault {
    // Capture all the binding specific properties
    // Set a comparator so tha httpLocations are stored in decending order
    Map httpLocationTable = new TreeMap(new Comparator() {

        public int compare(Object o1, Object o2) {
            return (-1 * ((Comparable) o1).compareTo(o2));
        }
    });
    SOAPBindingExtensions soapBindingExtensions;
    try {
        soapBindingExtensions = (SOAPBindingExtensions) binding.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP));
    } catch (URISyntaxException e) {
        throw new AxisFault("Soap Binding Extention not found");
    }
    String soapVersion;
    if ((soapVersion = soapBindingExtensions.getSoapVersion()) != null) {
        if (soapVersion.equals(WSDL2Constants.SOAP_VERSION_1_1)) {
            axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
        } else {
            axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
        }
    } else {
        // Set the default to soap 1.2
        axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, WSDL20DefaultValueHolder.getDefaultValue(WSDL2Constants.ATTR_WSOAP_VERSION));
    }
    URI soapUnderlyingProtocol = soapBindingExtensions.getSoapUnderlyingProtocol();
    if (soapUnderlyingProtocol != null) {
        axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_PROTOCOL, soapUnderlyingProtocol.toString());
    }
    URI soapMepDefault = soapBindingExtensions.getSoapMepDefault();
    if (soapMepDefault != null) {
        axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_MEP, soapMepDefault.toString());
    }
    axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, soapBindingExtensions.getHttpContentEncodingDefault());
    axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE, createSoapModules(soapBindingExtensions.getSoapModules()));
    axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, soapBindingExtensions.getHttpQueryParameterSeparatorDefault());
    // Capture all the fault specific properties
    BindingFault[] bindingFaults = binding.getBindingFaults();
    for (int i = 0; i < bindingFaults.length; i++) {
        BindingFault bindingFault = bindingFaults[i];
        InterfaceFault interfaceFault = serviceInterface.getFromAllInterfaceFaults(((BindingFaultElement) bindingFault).getRef());
        AxisBindingMessage axisBindingFault = new AxisBindingMessage();
        axisBindingFault.setFault(true);
        axisBindingFault.setName(interfaceFault.getName().getLocalPart());
        axisBindingFault.setParent(axisBinding);
        addDocumentation(axisBindingFault, interfaceFault.toElement());
        SOAPBindingFaultExtensions soapBindingFaultExtensions;
        try {
            soapBindingFaultExtensions = (SOAPBindingFaultExtensions) bindingFault.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP));
        } catch (URISyntaxException e) {
            throw new AxisFault("Soap Binding Extention not found");
        }
        axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_HEADER, createHttpHeaders(soapBindingFaultExtensions.getHttpHeaders()));
        axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, soapBindingFaultExtensions.getHttpContentEncoding());
        axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_CODE, soapBindingFaultExtensions.getSoapFaultCode());
        axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_SUBCODES, soapBindingFaultExtensions.getSoapFaultSubcodes());
        axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_HEADER, createSoapHeaders(soapBindingFaultExtensions.getSoapHeaders()));
        axisBindingFault.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE, createSoapModules(soapBindingFaultExtensions.getSoapModules()));
        axisBinding.addFault(axisBindingFault);
    }
    // Capture all the binding operation specific properties
    BindingOperation[] bindingOperations = binding.getBindingOperations();
    for (int i = 0; i < bindingOperations.length; i++) {
        BindingOperation bindingOperation = bindingOperations[i];
        AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
        InterfaceOperation interfaceOperation = serviceInterface.getFromAllInterfaceOperations(((BindingOperationElement) bindingOperation).getRef());
        AxisOperation axisOperation = axisService.getOperation(interfaceOperation.getName());
        axisBindingOperation.setAxisOperation(axisOperation);
        axisBindingOperation.setParent(axisBinding);
        axisBindingOperation.setName(axisOperation.getName());
        addDocumentation(axisBindingOperation, bindingOperation.toElement());
        SOAPBindingOperationExtensions soapBindingOperationExtensions;
        try {
            soapBindingOperationExtensions = ((SOAPBindingOperationExtensions) bindingOperation.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP)));
        } catch (URISyntaxException e) {
            throw new AxisFault("Soap Binding Extention not found");
        }
        URI soapAction = soapBindingOperationExtensions.getSoapAction();
        if (soapAction != null && !"\"\"".equals(soapAction.toString())) {
            axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION, soapAction.toString());
        }
        axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE, createSoapModules(soapBindingOperationExtensions.getSoapModules()));
        URI soapMep = soapBindingOperationExtensions.getSoapMep();
        if (soapMep != null) {
            axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_MEP, soapMep.toString());
        }
        HTTPLocation httpLocation = soapBindingOperationExtensions.getHttpLocation();
        // If httpLocation is not null we should extract a constant part from it and add its value and the
        // corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
        // the operation name into this map.
        String httpLocationString = null;
        if (httpLocation != null) {
            String httpLocationTemplete = httpLocation.getOriginalLocation();
            axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
            httpLocationString = WSDLUtil.getConstantFromHTTPLocation(httpLocationTemplete, HTTPConstants.HEADER_POST);
        }
        if (httpLocationString != null) {
            // this map is used to dispatch operation based on request URI , in the HTTPLocationBasedDispatcher
            httpLocationTable.put(httpLocationString, axisOperation);
        }
        axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, soapBindingOperationExtensions.getHttpContentEncodingDefault());
        axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, soapBindingOperationExtensions.getHttpQueryParameterSeparator());
        BindingMessageReference[] bindingMessageReferences = bindingOperation.getBindingMessageReferences();
        for (int j = 0; j < bindingMessageReferences.length; j++) {
            BindingMessageReference bindingMessageReference = bindingMessageReferences[j];
            AxisBindingMessage axisBindingMessage = new AxisBindingMessage();
            axisBindingMessage.setParent(axisBindingOperation);
            addDocumentation(axisBindingMessage, bindingMessageReference.toElement());
            AxisMessage axisMessage = axisOperation.getMessage(bindingMessageReference.getInterfaceMessageReference().getMessageLabel().toString());
            axisBindingMessage.setAxisMessage(axisMessage);
            axisBindingMessage.setName(axisMessage.getName());
            axisBindingMessage.setDirection(axisMessage.getDirection());
            SOAPBindingMessageReferenceExtensions soapBindingMessageReferenceExtensions;
            try {
                soapBindingMessageReferenceExtensions = (SOAPBindingMessageReferenceExtensions) bindingMessageReference.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP));
            } catch (URISyntaxException e) {
                throw new AxisFault("Soap Binding Extention not found");
            }
            axisBindingMessage.setProperty(WSDL2Constants.ATTR_WHTTP_HEADER, createHttpHeaders(soapBindingMessageReferenceExtensions.getHttpHeaders()));
            axisBindingMessage.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, soapBindingMessageReferenceExtensions.getHttpContentEncoding());
            axisBindingMessage.setProperty(WSDL2Constants.ATTR_WSOAP_HEADER, createSoapHeaders(soapBindingMessageReferenceExtensions.getSoapHeaders()));
            axisBindingMessage.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE, createSoapModules(soapBindingMessageReferenceExtensions.getSoapModules()));
            axisBindingOperation.addChild(axisMessage.getDirection(), axisBindingMessage);
        }
        BindingFaultReference[] bindingFaultReferences = bindingOperation.getBindingFaultReferences();
        for (int j = 0; j < bindingFaultReferences.length; j++) {
            BindingFaultReference bindingFaultReference = bindingFaultReferences[j];
            AxisBindingMessage axisBindingMessageFault = new AxisBindingMessage();
            addDocumentation(axisBindingMessageFault, bindingFaultReference.toElement());
            axisBindingMessageFault.setParent(axisBindingOperation);
            axisBindingMessageFault.setFault(true);
            axisBindingMessageFault.setName(bindingFaultReference.getInterfaceFaultReference().getInterfaceFault().getName().getLocalPart());
            SOAPBindingFaultReferenceExtensions soapBindingFaultReferenceExtensions;
            try {
                soapBindingFaultReferenceExtensions = (SOAPBindingFaultReferenceExtensions) bindingFaultReference.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP));
            } catch (URISyntaxException e) {
                throw new AxisFault("Soap Binding Extention not found");
            }
            axisBindingMessageFault.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE, createSoapModules(soapBindingFaultReferenceExtensions.getSoapModules()));
            axisBindingOperation.addFault(axisBindingMessageFault);
        }
        axisBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
        axisBinding.addChild(axisBindingOperation.getName(), axisBindingOperation);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) BindingFault(org.apache.woden.wsdl20.BindingFault) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) InterfaceOperation(org.apache.woden.wsdl20.InterfaceOperation) Comparator(java.util.Comparator) BindingMessageReference(org.apache.woden.wsdl20.BindingMessageReference) BindingOperation(org.apache.woden.wsdl20.BindingOperation) SOAPBindingExtensions(org.apache.woden.wsdl20.extensions.soap.SOAPBindingExtensions) SOAPBindingFaultReferenceExtensions(org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultReferenceExtensions) BindingFaultReference(org.apache.woden.wsdl20.BindingFaultReference) SOAPBindingMessageReferenceExtensions(org.apache.woden.wsdl20.extensions.soap.SOAPBindingMessageReferenceExtensions) SOAPBindingOperationExtensions(org.apache.woden.wsdl20.extensions.soap.SOAPBindingOperationExtensions) TreeMap(java.util.TreeMap) Endpoint(org.apache.woden.wsdl20.Endpoint) InterfaceFault(org.apache.woden.wsdl20.InterfaceFault) SOAPBindingFaultExtensions(org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultExtensions) HTTPLocation(org.apache.woden.wsdl20.extensions.http.HTTPLocation) Map(java.util.Map) HashMap(java.util.HashMap) NamespaceMap(org.apache.ws.commons.schema.utils.NamespaceMap) TreeMap(java.util.TreeMap)

Example 2 with SOAPBindingExtensions

use of org.apache.woden.wsdl20.extensions.soap.SOAPBindingExtensions in project axis-axis2-java-core by apache.

the class WSDL20ToAxisServiceBuilder method processEndpoints.

private void processEndpoints(Interface serviceInterface) throws AxisFault {
    Endpoint[] endpoints = wsdlService.getEndpoints();
    if (endpoints.length == 0) {
        throw new AxisFault("No endpoints found in the WSDL");
    }
    processedBindings = new HashMap();
    Endpoint endpoint = null;
    // 3. Use the first endpoint
    if (this.interfaceName != null) {
        for (int i = 0; i < endpoints.length; ++i) {
            if (this.interfaceName.equals(endpoints[i].getName().toString())) {
                endpoint = endpoints[i];
                // found it.  Stop looking
                break;
            }
        }
        if (endpoint == null) {
            throw new AxisFault("No endpoint found for the given name :" + this.interfaceName);
        }
        axisService.addEndpoint(endpoint.getName().toString(), processEndpoint(endpoint, serviceInterface));
    } else if (this.isCodegen && !this.isAllPorts) {
        Endpoint soap11Endpoint = null;
        for (int i = 0; i < endpoints.length; ++i) {
            Binding binding = endpoints[i].getBinding();
            if (WSDL2Constants.URI_WSDL2_SOAP.equals(binding.getType().toString())) {
                SOAPBindingExtensions soapBindingExtensions;
                try {
                    soapBindingExtensions = (SOAPBindingExtensions) binding.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_SOAP));
                } catch (URISyntaxException e) {
                    throw new AxisFault("Soap Binding Extention not found");
                }
                if (!WSDL2Constants.SOAP_VERSION_1_1.equals(soapBindingExtensions.getSoapVersion())) {
                    endpoint = endpoints[i];
                    // found it.  Stop looking
                    break;
                } else if (soap11Endpoint == null) {
                    soap11Endpoint = endpoints[i];
                }
            }
        }
        if (endpoint == null) {
            endpoint = endpoints[0];
        }
        axisService.addEndpoint(endpoint.getName().toString(), processEndpoint(endpoint, serviceInterface));
    } else {
        for (int i = 0; i < endpoints.length; i++) {
            axisService.addEndpoint(endpoints[i].getName().toString(), processEndpoint(endpoints[i], serviceInterface));
        }
    }
    if (endpoint == null && endpoints.length > 0) {
        endpoint = endpoints[0];
    }
    if (endpoint != null) {
        axisService.setEndpointName(endpoint.getName().toString());
        axisService.setBindingName(endpoint.getBinding().getName().getLocalPart());
        axisService.setEndpointURL(endpoint.getAddress().toString());
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) Binding(org.apache.woden.wsdl20.Binding) Endpoint(org.apache.woden.wsdl20.Endpoint) SOAPBindingExtensions(org.apache.woden.wsdl20.extensions.soap.SOAPBindingExtensions) HashMap(java.util.HashMap) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Endpoint(org.apache.woden.wsdl20.Endpoint)

Aggregations

URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2 AxisFault (org.apache.axis2.AxisFault)2 Endpoint (org.apache.woden.wsdl20.Endpoint)2 SOAPBindingExtensions (org.apache.woden.wsdl20.extensions.soap.SOAPBindingExtensions)2 Comparator (java.util.Comparator)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Binding (org.apache.woden.wsdl20.Binding)1 BindingFault (org.apache.woden.wsdl20.BindingFault)1 BindingFaultReference (org.apache.woden.wsdl20.BindingFaultReference)1 BindingMessageReference (org.apache.woden.wsdl20.BindingMessageReference)1 BindingOperation (org.apache.woden.wsdl20.BindingOperation)1 InterfaceFault (org.apache.woden.wsdl20.InterfaceFault)1 InterfaceOperation (org.apache.woden.wsdl20.InterfaceOperation)1 HTTPLocation (org.apache.woden.wsdl20.extensions.http.HTTPLocation)1 SOAPBindingFaultExtensions (org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultExtensions)1 SOAPBindingFaultReferenceExtensions (org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultReferenceExtensions)1 SOAPBindingMessageReferenceExtensions (org.apache.woden.wsdl20.extensions.soap.SOAPBindingMessageReferenceExtensions)1