|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
SOAP : Name space in message element, not in envelope |
« View previous topic :: View next topic » |
Author |
Message
|
hongabonga |
Posted: Wed Feb 16, 2011 10:56 pm Post subject: SOAP : Name space in message element, not in envelope |
|
|
 Novice
Joined: 15 Feb 2011 Posts: 24
|
Hi Friends,
I am facing this particular problem where my SOAP reply message is having the namespace declaration in each of its elements. However, I want it to be in the envelope.
Here are the codes:
SOAP REQ:
Code: |
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://www.hongabonga.com/students/reqreply">
<soapenv:Header/>
<soapenv:Body>
<req:STUDENT_NAME>ANKUR</req:STUDENT_NAME>
</soapenv:Body>
</soapenv:Envelope> |
SOAP RESP:
Code: |
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<NS1:STUDENT_PERCENTAGE xmlns:NS1="http://www.hongabonga.com/students/reqreply">10</NS1:STUDENT_PERCENTAGE>
</soapenv:Body>
</soapenv:Envelope> |
ESQL:
Code: |
DECLARE ns NAMESPACE 'http://www.hongabonga.com/students/reqreply';
CREATE COMPUTE MODULE SOAPTestFlow_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
SET OutputRoot.XMLNSC.ns:STUDENT_PERCENTAGE=10;
RETURN TRUE;
END;
END MODULE; |
XSD:
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2010 rel. 3 (http://www.altova.com) by Unpacker (Unpacker) -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified" targetNamespace="http://www.hongabonga.com/students/reqreply"
xmlns:stu_type_ns="http://www.hongabonga.com/students/reqreply"
>
<xsd:simpleType name="STUDENT_NAME_TYPE">
<xsd:restriction base="xsd:string">
<xsd:minLength value="2"/>
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="STUDENT_PERCENTAGE_TYPE">
<xsd:restriction base="xsd:int"/>
</xsd:simpleType>
<xsd:element name="STUDENT_NAME" type="stu_type_ns:STUDENT_NAME_TYPE" />
<xsd:element name="STUDENT_PERCENTAGE" type="stu_type_ns:STUDENT_PERCENTAGE_TYPE" />
</xsd:schema>
|
WSDL:
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2010 rel. 3 (http://www.altova.com) by Unpacker (Unpacker) -->
<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:xsd="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://www.hongabonga.com/students" xmlns:stu_ns="http://www.hongabonga.com/students/reqreply" targetNamespace="http://www.hongabonga.com/students">
<wsdl:types>
<xsd:schema targetNamespace="http://www.hongabonga.com/students">
<xsd:import namespace="http://www.hongabonga.com/students/reqreply" schemaLocation="stu_v01.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="StudentMessageRequest">
<wsdl:part name="StudentMessageReq" element="stu_ns:STUDENT_NAME"/>
</wsdl:message>
<wsdl:message name="StudentMessageResponse">
<wsdl:part name="StudentMessageResp" element="stu_ns:STUDENT_PERCENTAGE"/>
</wsdl:message>
<wsdl:portType name="StudentMessagePortType">
<wsdl:operation name="TransferStudentMessage">
<wsdl:input message="tns:StudentMessageRequest"/>
<wsdl:output message="tns:StudentMessageResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="StudentMessageBinding" type="tns:StudentMessagePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="TransferStudentMessage">
<soap:operation soapAction="http://www.hongabonga.com/students"/>
<wsdl:input>
<soap:body parts="StudentMessageReq" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body parts="StudentMessageResp" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="StudentMessageService">
<wsdl:port name="StudentMessageServiceDevPort" binding="tns:StudentMessageBinding">
<soap:address location="http://www.hongabonga.com/StudentMessageServicePort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions> |
I did some research, and yes, the two types of SOAP replies are semantically exactly the same. However, it is a requirement here and I have to come by some solutions.
I have found some suggestions and tried with the
Code: |
elementFormDefault="unqualified" attributeFormDefault="unqualified" |
attributes, like making them qualified etc. No help so far.
Please help me in this regard.
Many thanks in advance.  |
|
Back to top |
|
 |
fatherjack |
Posted: Thu Feb 17, 2011 1:19 am Post subject: Re: SOAP : Name space in message element, not in envelope |
|
|
 Knight
Joined: 14 Apr 2010 Posts: 522 Location: Craggy Island
|
hongabonga wrote: |
However, it is a requirement here |
Why is it a requirement? As you said yourself...
Quote: |
the two types of SOAP replies are semantically exactly the same. |
So what difference does it make? _________________ Never let the facts get in the way of a good theory. |
|
Back to top |
|
 |
hongabonga |
Posted: Thu Feb 17, 2011 1:42 am Post subject: |
|
|
 Novice
Joined: 15 Feb 2011 Posts: 24
|
Yes, correct question. Even I asked the same question at first.
However, to illustrate a little, in our organization, the testing team has raised a defect on this issue. After a brief discussion with them, we are still at the same point, that the reply must come in the other format(i.e., all namespace declarations in envelope).
That is why I am stuck.
Actually the example SOAP req, reply and even the XSD/WSDLs are dummy ones. I had to come up with these(exactly same grammar) because I can not show here the artifacts that I am using in the project. Sorry.
So, Please help. |
|
Back to top |
|
 |
mgk |
Posted: Thu Feb 17, 2011 1:58 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Assuming you are using the SOAP nodes, then rather than this:
Code: |
SET OutputRoot.XMLNSC.ns:STUDENT_PERCENTAGE=10; |
Which causes the SOAP Reply node to automatically add an envelope for you ( but all namespaces are declared in the body) you could try this:
Code: |
SET OutputRoot.SOAP.Body.ns:STUDENT_PERCENTAGE=10; |
This will use the SOAP domain which is designed for use with the SOAP nodes
You can then use the SOAP.Context to declare namespaces that should be added to the SOAP Envelope, like this:
Code: |
SET OutputRoot.SOAP.Context.Namespace.(SOAP.NamespaceDecl)xmlns:ns1=
'http://a/b/c/myNamespace'; |
Note that ideally you would put this line before the one that creates the body above.
For more details see this article:
http://www.ibm.com/developerworks/webservices/library/ws-soapnode2
Hopefully this will help,
Kind regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
hongabonga |
Posted: Tue Feb 22, 2011 7:45 am Post subject: |
|
|
 Novice
Joined: 15 Feb 2011 Posts: 24
|
First of all, Thanks a Lot mgk. It works.
2nd, I did go through the link you provided and understood the context described there. However, its still unclear to me how this line of yours does the magic.
This line I am talking about:
Code: |
SET OutputRoot.SOAP.Context.Namespace.(SOAP.NamespaceDecl)xmlns:ns1=
'http://a/b/c/myNamespace'; |
Because, using SOAP instead of XMLNSC alone, does not do the job. I tested it.
Can you please explain?  |
|
Back to top |
|
 |
mgk |
Posted: Tue Feb 22, 2011 9:57 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Quote: |
Can you please explain? |
I'll try
The SOAP Domain is designed for working with SOAP messages and so it is usually the best choice for SOAP. And the SOAP domain has a Context section which includes meta data about the wsdl etc for Inbound messages. For outpbound messages it allows you to define the namespaces and their prefixes and uses them when building the envelope. That's why you need both, as you never construct the Envelope directly using the SOAP domain - you only need to define the namesapces and it does the rest...
I hope that covers it...
Kind Regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
hongabonga |
Posted: Tue Feb 22, 2011 10:36 am Post subject: |
|
|
 Novice
Joined: 15 Feb 2011 Posts: 24
|
Hey, thanks a lot for the quick reply.
I guess, after your explanation, I have a better idea of it now.
So, what I understand, as I am defining the namespace in the context beforehand, it is not redefining it in each individual element, right? |
|
Back to top |
|
 |
mgk |
Posted: Tue Feb 22, 2011 10:38 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Quote: |
I am defining the namespace in the context beforehand, it is not redefining it in each individual element, right? |
Correct.
Kind Regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
hongabonga |
Posted: Tue Feb 22, 2011 10:45 am Post subject: |
|
|
 Novice
Joined: 15 Feb 2011 Posts: 24
|
It was really a learning experience.  |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|