Wednesday, January 26, 2011

W S D L - 1.1 - SOAP 1.2 Binding

Calculator Service (Addition):

Step 1 (Single Operation Addition):

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://sonianu.com.ws" targetNamespace="http://sonianu.com.ws">
<wsdl:types>
<xs:schema targetNamespace="http://sonianu.com.ws" elementFormDefault="qualified"/>
</wsdl:types>
<wsdl:message name="AddRequest">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:message name="AddResponse">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="CalculatorPortType">
<wsdl:operation name="AddOperation">
<wsdl:input message="tns:AddRequest"/>
<wsdl:output message="tns:AddResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculatorBinding" type="tns:CalculatorPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="AddOperation">
<soap:operation soapAction="urn:#AddOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalculatorService">
<wsdl:port name="CalculatorPort" binding="tns:CalculatorBinding">
<soap:address location="No target address"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Step 2 (Added another operation Substraction):

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://sonianu.com.ws" targetNamespace="http://sonianu.com.ws">
<wsdl:types>
<xs:schema targetNamespace="http://sonianu.com.ws" elementFormDefault="qualified"/>
</wsdl:types>
<wsdl:message name="AddRequest">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:message name="AddResponse">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:message name="SubRequest">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:message name="SubResponse">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="CalculatorPortType">
<wsdl:operation name="AddOperation">
<wsdl:input message="tns:AddRequest"/>
<wsdl:output message="tns:AddResponse"/>
</wsdl:operation>
<wsdl:operation name="SubOperation">
<wsdl:input message="tns:SubRequest"/>
<wsdl:output message="tns:SubResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculatorBinding" type="tns:CalculatorPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="AddOperation">
<soap:operation soapAction="urn:#AddOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="SubOperation">
<soap:operation soapAction="urn:#AddOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalculatorService">
<wsdl:port name="CalculatorPort" binding="tns:CalculatorBinding">
<soap:address location="No target address"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


Step 3 (Add Custom SOAP Fault & Header):

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://sonianu.com.ws" targetNamespace="http://sonianu.com.ws">
<wsdl:types>
<xs:schema targetNamespace="http://sonianu.com.ws" elementFormDefault="qualified">
            <xs:complexType name="MessageType">
                <xs:sequence>
                    <xs:element name="code" type="xs:string"/>
                    <xs:element minOccurs="0" name="text" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="MessagesType">
                <xs:sequence>
                    <xs:element maxOccurs="unbounded" minOccurs="0" name="message" nillable="true" type="tns:MessageType"/>
                </xs:sequence>
            </xs:complexType>
  <xs:complexType name="ExceptionType">
                <xs:sequence>
                    <xs:element name="messages" nillable="true" type="tns:MessagesType"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="RequestHeaderType">
                <xs:sequence>
                    <xs:element name="timestamp" type="xs:dateTime"/>
                    <xs:element name="sourceSystemId" type="xs:token"/>
                    <xs:element minOccurs="0" name="sourceSystemUserId" type="xs:token"/>
                    <xs:element name="sourceServerId" type="xs:token"/>
                    <xs:element name="trackingId" type="xs:token"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="ResponseHeaderType">
                <xs:sequence>
                    <xs:element name="timestamp" type="xs:dateTime"/>
                    <xs:element name="trackingId" type="xs:token"/>
                </xs:sequence>
            </xs:complexType>
            <xs:element name="serviceFault" type="tns:ExceptionType"/>
            <xs:element name="requestHeader" type="tns:RequestHeaderType"/>             
            <xs:element name="responseHeader" type="tns:ResponseHeaderType"/>
            </xs:schema>
</wsdl:types>
<wsdl:message name="AddRequest">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:message name="AddResponse">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:message name="CalculatorServiceRequestHeader">
<wsdl:part name="request_header" element="tns:requestHeader"/>
</wsdl:message>
<wsdl:message name="CalculatorServiceResponseHeader">
<wsdl:part name="response_header" element="tns:responseHeader"/>
</wsdl:message>
<wsdl:message name="CalculatorServiceFault">
<wsdl:part name="service_fault" element="tns:serviceFault"/>
</wsdl:message>
<wsdl:portType name="CalculatorPortType">
<wsdl:operation name="AddOperation">
<wsdl:input message="tns:AddRequest"/>
<wsdl:output message="tns:AddResponse"/>
<wsdl:fault name="CalculatorServiceFault" message="tns:CalculatorServiceFault"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculatorBinding" type="tns:CalculatorPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="AddOperation">
<soap:operation soapAction="AddOperation" />
<wsdl:input>
<soap:header use="literal" message="tns:CalculatorServiceRequestHeader" part="request_header" />
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:header use="literal" message="tns:CalculatorServiceResponseHeader" part="response_header" />
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="CalculatorServiceFault">
<soap:fault use="literal"  name="CalculatorServiceFault" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalculatorService">
<wsdl:port name="CalculatorPort" binding="tns:CalculatorBinding">
<soap:address location="http://sonianu.com/Calculator/ver01/CalculatorService?WSDL"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Step 4 (Add WS Policy - SAML):

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://sonianu.com.ws" targetNamespace="http://sonianu.com.ws" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wssp="http://www.bea.com/wls90/security/policy" xmlns:s0="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsdl:types>
<xs:schema targetNamespace="http://sonianu.com.ws" elementFormDefault="qualified">
            <xs:complexType name="MessageType">
                <xs:sequence>
                    <xs:element name="code" type="xs:string"/>
                    <xs:element minOccurs="0" name="text" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="MessagesType">
                <xs:sequence>
                    <xs:element maxOccurs="unbounded" minOccurs="0" name="message" nillable="true" type="tns:MessageType"/>
                </xs:sequence>
            </xs:complexType>
  <xs:complexType name="ExceptionType">
                <xs:sequence>
                    <xs:element name="messages" nillable="true" type="tns:MessagesType"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="RequestHeaderType">
                <xs:sequence>
                    <xs:element name="timestamp" type="xs:dateTime"/>
                    <xs:element name="sourceSystemId" type="xs:token"/>
                    <xs:element minOccurs="0" name="sourceSystemUserId" type="xs:token"/>
                    <xs:element name="sourceServerId" type="xs:token"/>
                    <xs:element name="trackingId" type="xs:token"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="ResponseHeaderType">
                <xs:sequence>
                    <xs:element name="timestamp" type="xs:dateTime"/>
                    <xs:element name="trackingId" type="xs:token"/>
                </xs:sequence>
            </xs:complexType>
            <xs:element name="serviceFault" type="tns:ExceptionType"/>
            <xs:element name="requestHeader" type="tns:RequestHeaderType"/>             
            <xs:element name="responseHeader" type="tns:ResponseHeaderType"/>
            </xs:schema>
</wsdl:types>
<wsdl:message name="AddRequest">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:message name="AddResponse">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:message name="CalculatorServiceRequestHeader">
<wsdl:part name="request_header" element="tns:requestHeader"/>
</wsdl:message>
<wsdl:message name="CalculatorServiceResponseHeader">
<wsdl:part name="response_header" element="tns:responseHeader"/>
</wsdl:message>
<wsdl:message name="CalculatorServiceFault">
<wsdl:part name="service_fault" element="tns:serviceFault"/>
</wsdl:message>
<wsdl:portType name="CalculatorPortType">
<wsdl:operation name="AddOperation">
<wsdl:input message="tns:AddRequest"/>
<wsdl:output message="tns:AddResponse"/>
<wsdl:fault name="CalculatorServiceFault" message="tns:CalculatorServiceFault"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculatorBinding" type="tns:CalculatorPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="AddOperation">
<soap:operation soapAction="AddOperation" />
<wsdl:input>
                <wsp:Policy>
                    <wsp:PolicyReference URI="#Auth.xml"/>
                </wsp:Policy>
<soap:header use="literal" message="tns:CalculatorServiceRequestHeader" part="request_header" />
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:header use="literal" message="tns:CalculatorServiceResponseHeader" part="response_header" />
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="CalculatorServiceFault">
<soap:fault use="literal"  name="CalculatorServiceFault" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalculatorService">
<wsdl:port name="CalculatorPort" binding="tns:CalculatorBinding">
<soap:address location="http://sonianu.com/Calculator/ver01/CalculatorService?WSDL"/>
</wsdl:port>
</wsdl:service>
    <wsp:UsingPolicy wsdl:Required="true"/>
    <wsp:Policy s0:Id="Auth.xml">
        <wssp:Identity xmlns:wssp="http://www.bea.com/wls90/security/policy">
            <wssp:SupportedTokens>
                <wssp:SecurityToken TokenType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken">
                    <wssp:UsePassword Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"/>
                </wssp:SecurityToken>
            </wssp:SupportedTokens>
        </wssp:Identity>
    </wsp:Policy>
</wsdl:definitions>

Web Service Policy: Java EE [On Weblogic Server we find these files @ Oracle\Middleware\Oracle_Home\wlserver\server\lib\weblogic-classes.jar\weblogic\wsee\policy\runtime\ ]

Which kind of WSDL to use: Version of WSDL to Use: "RPC/encoded" , "RPC/literal", "Document/encoded", "Document/literal"

No comments:

Post a Comment