Search in sources :

Example 1 with InterfaceFault

use of org.apache.woden.wsdl20.InterfaceFault 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 InterfaceFault

use of org.apache.woden.wsdl20.InterfaceFault in project axis-axis2-java-core by apache.

the class WSDL20ToAxisServiceBuilder method populateOperations.

private AxisOperation populateOperations(InterfaceOperation operation) throws AxisFault {
    QName opName = operation.getName();
    // Copy Name Attribute
    AxisOperation axisOperation = axisService.getOperation(opName);
    if (axisOperation == null) {
        URI pattern = operation.getMessageExchangePattern();
        String MEP;
        if (pattern == null) {
            MEP = WSDL20DefaultValueHolder.getDefaultValue(WSDL2Constants.ATTR_WSOAP_MEP);
        } else {
            MEP = pattern.toString();
        }
        if (!isServerSide) {
            // If in the client, need to toggle in-out to out-in etc.
            if (WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) {
                MEP = WSDL2Constants.MEP_URI_OUT_IN;
            }
            if (WSDL2Constants.MEP_URI_IN_ONLY.equals(MEP)) {
                MEP = WSDL2Constants.MEP_URI_OUT_ONLY;
            }
            if (WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(MEP)) {
                MEP = WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN;
            }
        }
        axisOperation = AxisOperationFactory.getOperationDescription(MEP);
        axisOperation.setName(opName);
    }
    URI[] operationStyle = operation.getStyle();
    if (operationStyle != null && operationStyle.length > 0) {
        Parameter opStyleParameter = new Parameter();
        opStyleParameter.setName(WSDL2Constants.OPERATION_STYLE);
        opStyleParameter.setValue(operationStyle);
        axisOperation.addParameter(opStyleParameter);
    }
    addDocumentation(axisOperation, operation.toElement());
    // assuming the style of the operations of WSDL 2.0 is always document, for the time being :)
    // The following can be used to capture the wsdlx:safe attribute
    InterfaceOperationExtensions interfaceOperationExtensions;
    try {
        interfaceOperationExtensions = (InterfaceOperationExtensions) operation.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_EXTENSIONS));
    } catch (URISyntaxException e) {
        throw new AxisFault("WSDL2 extensions not defined for this operation");
    }
    if (interfaceOperationExtensions != null) {
        Parameter parameter = new Parameter(WSDL2Constants.ATTR_WSDLX_SAFE, Boolean.valueOf(interfaceOperationExtensions.isSafe()));
        axisOperation.addParameter(parameter);
    }
    RPCInterfaceOperationExtensions rpcInterfaceOperationExtensions;
    try {
        rpcInterfaceOperationExtensions = (RPCInterfaceOperationExtensions) operation.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_RPC));
    } catch (URISyntaxException e) {
        throw new AxisFault("WSDL2 extensions not defined for this operation");
    }
    if (rpcInterfaceOperationExtensions != null) {
        String rpcsig = "";
        Argument[] signatures = rpcInterfaceOperationExtensions.getRPCSignature();
        for (int i = 0; i < signatures.length; i++) {
            Argument sigArgument = signatures[i];
            rpcsig = rpcsig + sigArgument.getName().getLocalPart() + " " + sigArgument.getDirection() + " ";
        }
        Parameter parameter = new Parameter(WSDL2Constants.ATTR_WRPC_SIGNATURE, rpcsig);
        axisOperation.addParameter(parameter);
    }
    InterfaceMessageReference[] interfaceMessageReferences = operation.getInterfaceMessageReferences();
    for (int i = 0; i < interfaceMessageReferences.length; i++) {
        InterfaceMessageReference messageReference = interfaceMessageReferences[i];
        if (messageReference.getMessageLabel().equals(MessageLabel.IN)) {
            if (isServerSide) {
                createAxisMessage(axisOperation, messageReference, WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            } else {
                createAxisMessage(axisOperation, messageReference, WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
            }
        } else if (messageReference.getMessageLabel().equals(MessageLabel.OUT)) {
            if (isServerSide) {
                createAxisMessage(axisOperation, messageReference, WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
            } else {
                createAxisMessage(axisOperation, messageReference, WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            }
        }
    }
    // add operation level faults
    InterfaceFaultReference[] faults = operation.getInterfaceFaultReferences();
    for (int i = 0; i < faults.length; i++) {
        AxisMessage faultMessage = new AxisMessage();
        InterfaceFaultReference interfaceFaultReference = faults[i];
        faultMessage.setDirection(interfaceFaultReference.getDirection().toString());
        InterfaceFault interfaceFault = interfaceFaultReference.getInterfaceFault();
        if (interfaceFault == null) {
            throw new AxisFault("Interface Fault reference defined in operation " + opName + " cannot be found in interface");
        }
        // retrieve interface fault element
        InterfaceFaultElement interfaceFaultElement = interfaceFault.toElement();
        // drill down to get actual interface fault element definition
        QNameTokenUnion interfaceFaultElementDef = interfaceFaultElement.getElement();
        QName qName = interfaceFaultElementDef.getQName();
        String name = qName.getLocalPart();
        faultMessage.setElementQName(qName);
        faultMessage.setName(name);
        axisOperation.setFaultMessages(faultMessage);
    }
    return axisOperation;
}
Also used : AxisFault(org.apache.axis2.AxisFault) QNameTokenUnion(org.apache.woden.types.QNameTokenUnion) Argument(org.apache.woden.wsdl20.extensions.rpc.Argument) InterfaceFaultElement(org.apache.woden.wsdl20.xml.InterfaceFaultElement) QName(javax.xml.namespace.QName) InterfaceFaultReference(org.apache.woden.wsdl20.InterfaceFaultReference) URISyntaxException(java.net.URISyntaxException) RPCInterfaceOperationExtensions(org.apache.woden.wsdl20.extensions.rpc.RPCInterfaceOperationExtensions) URI(java.net.URI) Endpoint(org.apache.woden.wsdl20.Endpoint) InterfaceMessageReference(org.apache.woden.wsdl20.InterfaceMessageReference) InterfaceFault(org.apache.woden.wsdl20.InterfaceFault) InterfaceOperationExtensions(org.apache.woden.wsdl20.extensions.InterfaceOperationExtensions) RPCInterfaceOperationExtensions(org.apache.woden.wsdl20.extensions.rpc.RPCInterfaceOperationExtensions)

Example 3 with InterfaceFault

use of org.apache.woden.wsdl20.InterfaceFault in project axis-axis2-java-core by apache.

the class WSDL20ToAxisServiceBuilder method processHTTPBindingExtention.

private void processHTTPBindingExtention(Binding binding, AxisBinding axisBinding, Interface serviceInterface) throws AxisFault {
    Map<String, AxisOperation> httpLocationTable = createHttpLocationTable();
    // Capture all the binding specific properties
    HTTPBindingExtensions httpBindingExtensions;
    try {
        httpBindingExtensions = (HTTPBindingExtensions) binding.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_HTTP));
    } catch (URISyntaxException e) {
        throw new AxisFault("HTTP Binding Extention not found");
    }
    String httpMethodDefault = httpBindingExtensions.getHttpMethodDefault();
    axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, httpMethodDefault);
    axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, httpBindingExtensions.getHttpQueryParameterSeparatorDefault());
    axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, httpBindingExtensions.getHttpContentEncodingDefault());
    // 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());
        HTTPBindingFaultExtensions httpBindingFaultExtensions;
        try {
            httpBindingFaultExtensions = (HTTPBindingFaultExtensions) bindingFault.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_HTTP));
        } catch (URISyntaxException e) {
            throw new AxisFault("HTTP Binding Extention not found");
        }
        axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_CODE, httpBindingFaultExtensions.getHttpErrorStatusCode().getCode());
        axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_HEADER, createHttpHeaders(httpBindingFaultExtensions.getHttpHeaders()));
        axisBindingFault.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, httpBindingFaultExtensions.getHttpContentEncoding());
        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());
        HTTPBindingOperationExtensions httpBindingOperationExtensions;
        try {
            httpBindingOperationExtensions = ((HTTPBindingOperationExtensions) bindingOperation.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_HTTP)));
        } catch (URISyntaxException e) {
            throw new AxisFault("HTTP Binding Extention not found");
        }
        axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_FAULT_SERIALIZATION, httpBindingOperationExtensions.getHttpFaultSerialization());
        axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_INPUT_SERIALIZATION, httpBindingOperationExtensions.getHttpInputSerialization());
        String httpMethod = httpBindingOperationExtensions.getHttpMethod();
        if (httpMethod == null) {
            if (httpMethodDefault != null) {
                httpMethod = httpMethodDefault;
            } else {
                Boolean safeParameter = (Boolean) axisOperation.getParameterValue(WSDL2Constants.ATTR_WSDLX_SAFE);
                if (safeParameter != null && safeParameter.booleanValue()) {
                    httpMethod = HTTPConstants.HEADER_GET;
                } else {
                    httpMethod = HTTPConstants.HEADER_POST;
                }
            }
        }
        axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, httpMethod);
        HTTPLocation httpLocation = httpBindingOperationExtensions.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 = "";
        if (httpLocation != null) {
            String httpLocationTemplete = httpLocation.getOriginalLocation();
            axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocationTemplete);
            httpLocationString = WSDLUtil.getConstantFromHTTPLocation(httpLocationTemplete, httpMethod);
        }
        httpLocationTable.put(httpLocationString, axisOperation);
        axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_IGNORE_UNCITED, httpBindingOperationExtensions.isHttpLocationIgnoreUncited());
        axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_OUTPUT_SERIALIZATION, httpBindingOperationExtensions.getHttpOutputSerialization());
        axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, httpBindingOperationExtensions.getHttpQueryParameterSeparator());
        axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, httpBindingOperationExtensions.getHttpContentEncodingDefault());
        BindingMessageReference[] bindingMessageReferences = bindingOperation.getBindingMessageReferences();
        for (int j = 0; j < bindingMessageReferences.length; j++) {
            BindingMessageReference bindingMessageReference = bindingMessageReferences[j];
            AxisBindingMessage axisBindingMessage = new AxisBindingMessage();
            axisBindingMessage.setParent(axisBindingOperation);
            AxisMessage axisMessage = axisOperation.getMessage(bindingMessageReference.getInterfaceMessageReference().getMessageLabel().toString());
            axisBindingMessage.setAxisMessage(axisMessage);
            axisBindingMessage.setName(axisMessage.getName());
            axisBindingMessage.setDirection(axisMessage.getDirection());
            addDocumentation(axisBindingMessage, bindingMessageReference.toElement());
            HTTPBindingMessageReferenceExtensions httpBindingMessageReferenceExtensions;
            try {
                httpBindingMessageReferenceExtensions = (HTTPBindingMessageReferenceExtensions) bindingMessageReference.getComponentExtensionContext(new URI(WSDL2Constants.URI_WSDL2_HTTP));
            } catch (URISyntaxException e) {
                throw new AxisFault("HTTP Binding Extention not found");
            }
            axisBindingMessage.setProperty(WSDL2Constants.ATTR_WHTTP_HEADER, createHttpHeaders(httpBindingMessageReferenceExtensions.getHttpHeaders()));
            axisBindingMessage.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING, httpBindingMessageReferenceExtensions.getHttpContentEncoding());
            axisBindingOperation.addChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE, axisBindingMessage);
        }
        BindingFaultReference[] bindingFaultReferences = bindingOperation.getBindingFaultReferences();
        for (int j = 0; j < bindingFaultReferences.length; j++) {
            BindingFaultReference bindingFaultReference = bindingFaultReferences[j];
            AxisBindingMessage axisBindingMessageFault = new AxisBindingMessage();
            axisBindingMessageFault.setFault(true);
            axisBindingMessageFault.setName(bindingFaultReference.getInterfaceFaultReference().getInterfaceFault().getName().getLocalPart());
            axisBindingMessageFault.setParent(axisBindingOperation);
            axisBindingOperation.addFault(axisBindingMessageFault);
            addDocumentation(axisBindingMessageFault, bindingFaultReference.toElement());
        }
        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) BindingMessageReference(org.apache.woden.wsdl20.BindingMessageReference) BindingOperation(org.apache.woden.wsdl20.BindingOperation) BindingFaultReference(org.apache.woden.wsdl20.BindingFaultReference) HTTPBindingExtensions(org.apache.woden.wsdl20.extensions.http.HTTPBindingExtensions) Endpoint(org.apache.woden.wsdl20.Endpoint) InterfaceFault(org.apache.woden.wsdl20.InterfaceFault) HTTPBindingOperationExtensions(org.apache.woden.wsdl20.extensions.http.HTTPBindingOperationExtensions) HTTPBindingFaultExtensions(org.apache.woden.wsdl20.extensions.http.HTTPBindingFaultExtensions) HTTPBindingMessageReferenceExtensions(org.apache.woden.wsdl20.extensions.http.HTTPBindingMessageReferenceExtensions) HTTPLocation(org.apache.woden.wsdl20.extensions.http.HTTPLocation)

Aggregations

URI (java.net.URI)3 URISyntaxException (java.net.URISyntaxException)3 AxisFault (org.apache.axis2.AxisFault)3 Endpoint (org.apache.woden.wsdl20.Endpoint)3 InterfaceFault (org.apache.woden.wsdl20.InterfaceFault)3 BindingFault (org.apache.woden.wsdl20.BindingFault)2 BindingFaultReference (org.apache.woden.wsdl20.BindingFaultReference)2 BindingMessageReference (org.apache.woden.wsdl20.BindingMessageReference)2 BindingOperation (org.apache.woden.wsdl20.BindingOperation)2 InterfaceOperation (org.apache.woden.wsdl20.InterfaceOperation)2 HTTPLocation (org.apache.woden.wsdl20.extensions.http.HTTPLocation)2 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 QName (javax.xml.namespace.QName)1 QNameTokenUnion (org.apache.woden.types.QNameTokenUnion)1 InterfaceFaultReference (org.apache.woden.wsdl20.InterfaceFaultReference)1 InterfaceMessageReference (org.apache.woden.wsdl20.InterfaceMessageReference)1 InterfaceOperationExtensions (org.apache.woden.wsdl20.extensions.InterfaceOperationExtensions)1