Tutorials to .com

Tutorials to .com » Jsp » Xml » Manually created namespace SOAP message processing

Manually created namespace SOAP message processing

Print View , by: iSee ,Total views: 11 ,Word Count: 1734 ,Date: Mon, 20 Apr 2009 Time: 9:50 PM


Introduction <br> <br> In a typical Web services scenario, the technology commonly used tool to deal with all namespace nuances. Sometimes, however, especially in the use of SAAJ (SOAP with Attachments API for Java) for a particular structure of Web services SOAP message, you will have to deal with namespace issues. Assist in the absence of any structural information of the circumstances - or some news - you can use the skills.

Although seemingly complex namespace, but you really only need to know the following rules of a short list:

If the WSDL style to RPC, it can be in the WSDL binding wsdlsoap: body elements in the view namespace.

If wsdlsoap: body have a namespace attribute (and Web Services Interoperability Organization (WS-I) of the Basic Profile (see references in part) the need for the RPC style attributes), then this is the SOAP message element namespace operations .

If wsdlsoap: body no namespace, then elements of the operation does not meet the requirement.

For the purposes of data elements:

If the element through the root element (not the root type) definition, it is the root element namespace namespace;

If not through the root element of the definition, then the element does not meet the requirements (for the description of rules please see the following part of elementFormDefault discussion.)

These are simple rules, but the same rules as the majority, need to be a little note. The rest of this article will demonstrate the use of various examples of these rules.

There are two common types of Web Services Description Language (WSDL) document: RPC / literal and document / literal package. Of course there are other types, but in this article contains only these two. (The details of various types of WSDL, see the article "Which style should I use the WSDL?" - See references.)

RPC / literal WSDL

1 in the list of RPC / literal WSDL three operations: op1, op2 and op3. Note WSDL file in bold to emphasize differences with the namespace.

List 1. RPC / literal WSDL
<? xml version = "1.0" encoding = "UTF-8"?>
<definitions
targetNamespace = "http://apiNamespace.com"
xmlns = "http://schemas.xmlsoap.org/wsdl/"
xmlns: tns = "http://apiNamespace.com"
xmlns: data = "http://dataNamespace.com"
xmlns: wsdlsoap = "http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<schema
targetNamespace = "http://refNamespace.com"
xmlns = "http://www.w3.org/2001/XMLSchema"
xmlns: tns = "http://refNamespace.com">
<element name="RefDataElem" type="int"/>
</ schema>
<schema
targetNamespace = "http://dataNamespace.com"
xmlns = "http://www.w3.org/2001/XMLSchema"
xmlns: ref = "http://refNamespace.com"
xmlns: tns = "http://dataNamespace.com"
xmlns: xsd = "http://www.w3.org/2001/XMLSchema">
<import namespace="http://refNamespace.com"/>
<complexType name="Data">
<sequence>
<element name="data1" type="int"/>
<element name="data2" type="int"/>
</ sequence>
</ complexType>
<element name = "DataElem" nillable =
"true" type = "tns: Data" />
<complexType name="Data2">
<sequence>
<element ref="ref:RefDataElem"/>
</ sequence>
</ complexType>
</ schema>
</ types>
<message name="op1Request">
<part name="in" type="data:Data"/>
</ message>
<message name="op1Response">
<part name = "op1Return"
type = "data: Data" />
</ message>
<message name="op2Request">
<part name="in" type="data:Data"/>
</ message>
<message name="op2Response">
<part name="op2Return" type="data:Data"/>
</ message>
<message name="op3Request">
<part name="in1" element="data:DataElem"/>
<part name="in2" type="data:Data2"/>
</ message>
<message name="op3Response">
<part name="op3Return" type="data:Data2"/>
</ message>
<portType name="Sample">
<operation name="op1">
<input message="tns:op1Request"/>
<output message="tns:op1Response"/>
</ operation>
<operation name="op2">
<input message="tns:op2Request"/>
<output message="tns:op2Response"/>
</ operation>
<operation name="op3">
<input message="tns:op3Request"/>
<output message="tns:op3Response"/>
</ operation>
</ portType>
<binding name="SampleSoapBinding" type="tns:Sample">
<wsdlsoap: binding style = "rpc" transport =
"http://schemas.xmlsoap.org/soap/http" />
<operation name="op1">
<wsdlsoap:operation soapAction=""/>
<input>
<wsdlsoap: body namespace =
"http://apiNamespace.com" use = "literal" />
</ input>
<output>
<wsdlsoap: body namespace =
"http://apiNamespace.com" use = "literal" />
</ output>
</ operation>
<operation name="op2">
<wsdlsoap:operation soapAction=""/>
<input>
<wsdlsoap: body namespace =
"http://op2Namespace.com" use = "literal" /> </ input>
<output>
<wsdlsoap: body namespace =
"http://op2Namespace.com" use = "literal" />
</ output>
</ operation>
<operation name="op3">
<wsdlsoap:operation soapAction=""/>
<input>
<wsdlsoap:body use="literal"/>
</ input>
<output>
<wsdlsoap:body use="literal"/>
</ output>
</ operation>
</ binding>
<service name="SampleService">
<port binding = "tns: SampleSoapBinding" name =
"Sample">
<wsdlsoap: address location =
"http://localhost:9080/RPCNamespaces/services/Sample" />
</ port>
</ service>
</ definitions>

WS-I compliance WS-I (see references) for the WSDL definition of standards compliance. Terms from two, op3 non-compliance with the RPC / literal WSDL: it is not in the binding wsdlsoap: body as defined in the namespace; its part cited the elements of news, rather than type. In this proposed can be used to demonstrate WS-I's Basic Profile to resolve the issue of some namespace.

See the bind operation for each of the wsdlsoap: body elements in the namespace. op1 and op2 are examples of rule 1.1 (see the contents of the SOAP message). op3 is an example of rule 1.2. op1 showed examples of the use of conventional targetNamespace - in this case is "http://apiNamespace.com" - as the namespace of the operation, but this is just usually. op2 namespace used in the WSDL will not be in use anywhere else. op3 no definition of any namespace.

A list of 2,3 and 4, respectively, showed op1, op2 and op3 the SOAP message. Attention to the news highlighted in bold with namespace.

List 2. Op1 the RPC / literal request / response SOAP message <soapenv: Envelope xmlns: soapenv =
"http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<p582:op1 xmlns:p582="http://apiNamespace.com">
<in>
<data1> 1 </ data1>
<data2> 2 </ data2>
</ in>
</ p582: op1>
</ soapenv: Body>
</ soapenv: Envelope>
<soapenv: Envelope xmlns: soapenv =
"http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<p582: op1Response xmlns: p582 =
"http://apiNamespace.com">
<op1Return>
<data1> 10 </ data1>
<data2> 20 </ data2>
</ op1Return>
</ p582: op1Response>
</ soapenv: Body>
</ soapenv: Envelope>

Already mentioned above, a list of 2 to comply with the rules of the SOAP message 1.1. op1 namespace for "http://apiNamespace.com". Such information to comply with the rules of the same 2.2. Not all the parameters of data through the definition of the root element, only the root type - data - as well as its sub-elements. Since the root element is not used, then these elements are not required.

List 3. Op2 of the RPC / literal request / response SOAP message <soapenv: Envelope xmlns: soapenv =
"http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<p999: op2 xmlns: p999 =
"http://op2Namespace.com">
<in>
<data1> 3 </ data1>
<data2> 4 </ data2>
</ in>
</ p999: op2>
</ soapenv: Body>
</ soapenv: Envelope>
<soapenv: Envelope xmlns: soapenv =
"http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<p999: op2Response xmlns: p999 =
"http://op2Namespace.com">
<op2Return>
<data1> 300 </ data


Java and XML Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.