Author |
Message
|
biswagourab |
Posted: Fri Apr 11, 2008 9:15 am Post subject: XMLNSC header building |
|
|
 Apprentice
Joined: 31 May 2005 Posts: 47 Location: London
|
Hi
Can anyone please tell me how to build the following header in ESQL.
<?xml version="1.0" encoding="utf-8" ?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c="http://www.w3.org/2001/XMLSchema">
<soapenv:Body>
I am trying to generate this ...but am only able to generate this
<?xml version="1.0" encoding="UTF-8"?>
<NS1:Envelope xmlns:NS1="http://schemas.xmlsoap.org/soap/envelope/">
<NS2:Body xmlns:NS2="http://www.brokersamplewshost.ibm.com">
Thanks in advance. _________________ _________________
Biswa Gourab Malla
IBM Certified System Administrator - WebSphere MQ, v6.0
IBM Certified System Administrator - Websphere Message Broker v6.0 |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Fri Apr 11, 2008 10:18 am Post subject: Re: XMLNSC header building |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
Check little example code below or other examples or docs:
Code: |
DECLARE mySoapNS NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
DECLARE q0 NAMESPACE 'http://www.server.com.pl/WSPilot/SimpleTypes';
CREATE FUNCTION CreateXMLNSSOAP()
BEGIN
DECLARE req REFERENCE TO OutputRoot;
CREATE LASTCHILD OF req DOMAIN('XMLNS') NAME 'XMLNS';
-- Add an XML declaration to the message
SET OutputRoot.XMLNS.(XML.XmlDecl) = '';
SET OutputRoot.XMLNS.(XML.XmlDecl).(XML.Version) = '1.0';
SET OutputRoot.XMLNS.(XML.XmlDecl).(XML.Encoding) = 'UTF-8';
-- Create the SOAP Envelope
SET OutputRoot.XMLNS.mySoapNS:Envelope.(XML.NamespaceDecl)xmlns:"SOAP-ENV" =
'http://schemas.xmlsoap.org/soap/envelope/' ;
SET OutputRoot.XMLNS.mySoapNS:Envelope.(XML.NamespaceDecl)xmlns:xsi =
'http://www.w3.org/2001/XMLSchema-instance' ;
SET OutputRoot.XMLNS.mySoapNS:Envelope.(XML.NamespaceDecl)xmlns:q0 = q0 ;
SET OutputRoot.XMLNS.mySoapNS:Envelope.(XML.NamespaceDecl)xmlns:xsd =
'http://www.w3.org/2001/XMLSchema' ;
SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.q0:addInt.intPair.v1=2;
SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.q0:addInt.intPair.v1=3;
END; |
_________________ Marcin
Last edited by marcin.kasinski on Fri Apr 11, 2008 10:20 am; edited 1 time in total |
|
Back to top |
|
 |
Gemz |
Posted: Fri Apr 11, 2008 10:18 am Post subject: |
|
|
 Centurion
Joined: 14 Jan 2008 Posts: 124
|
Can you please post the ESQL that you used to create your output.?
Thanks
Gemz |
|
Back to top |
|
 |
biswagourab |
Posted: Mon Apr 14, 2008 3:52 am Post subject: |
|
|
 Apprentice
Joined: 31 May 2005 Posts: 47 Location: London
|
Thanks marcin.kasinski  _________________ _________________
Biswa Gourab Malla
IBM Certified System Administrator - WebSphere MQ, v6.0
IBM Certified System Administrator - Websphere Message Broker v6.0 |
|
Back to top |
|
 |
paustin_ours |
Posted: Wed Feb 08, 2012 12:08 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
I know this is a pretty old post but am gonna ask for some help anyway!
here it goes,
As in the initial post, i am still getting NS1 in my output and not able to get a soapenv to appear.
This is expected
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
This is what am getting
<NS1:Envelope xmlns:NS1="http://schemas.xmlsoap.org/soap/envelope/"></NS1:Envelope>
My code:
Code: |
CALL CopyMessageHeaders();
-- CALL CopyEntireMessage();
CREATE LASTCHILD OF OutputRoot DOMAIN ('XMLNSC') NAME 'XMLNSC';
DECLARE mysoapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
SET OutputRoot.XMLNSC.mysoapenv:Envelope.(XML.NamespaceDecl)xmlns:"SOAP-ENV"='http://schemas.xmlsoap.org/soap/envelope/'; |
not sure what am missing. I am declaring the namespace mysoapenv. I read that NS1 shows up only if a namespace is not declared. Any pointers will be very helpful. Thanks. |
|
Back to top |
|
 |
adubya |
Posted: Wed Feb 08, 2012 12:31 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
How about
Code: |
SET OutputRoot.XMLNSC.mysoapenv:Envelope.(XML.NamespaceDecl)xmlns:soapenv=mysoapenv; |
? |
|
Back to top |
|
 |
paustin_ours |
Posted: Wed Feb 08, 2012 1:14 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
Just tried what you had suggested, still the same output, NS1:Envelope  |
|
Back to top |
|
 |
kimbert |
Posted: Wed Feb 08, 2012 1:44 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
You are getting confused.
This line:
Code: |
DECLARE mysoapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/'; |
only affects your ESQL. It is almost the same as
Code: |
DECLARE mysoapenv CHARACTER 'http://schemas.xmlsoap.org/soap/envelope/'; |
...except that you can use a NAMESPACE constant in ESQL path references using nice clean syntax. Like this:
Code: |
SET OutputRoot.XMLNS.mysoapenv:Envelope.mysoapenv:Header.(XMLNSC.Attribute)mustUnderstand="1"; |
However...this next line of ESQL does affect the output XML:
Code: |
SET OutputRoot.XMLNS.mysoapenv:Envelope.(XML.NamespaceDecl)xmlns:"SOAP-ENV" =
'http://schemas.xmlsoap.org/soap/envelope/' ; |
It is adding an xmlns attribute to the output message tree. The XMLNSC writer automatically detects xmlns attributes in the output message tree and it adjusts the namespace prefixes in the output message based on those xmlns attribute.
If you don't understand that last paragraph, then please read this: http://www.w3.org/TR/REC-xml-names/
...or else take the W3Schools tutorial on XML namespaces. |
|
Back to top |
|
 |
rekarm01 |
Posted: Wed Feb 08, 2012 1:47 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
paustin_ours wrote: |
Just tried what you had suggested, still the same output, NS1:Envelope  |
The XMLNSC parser expects XMLNSC constants:
Code: |
...(XMLNSC.NamespaceDecl)... |
|
|
Back to top |
|
 |
paustin_ours |
Posted: Wed Feb 08, 2012 2:16 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
Thanks for catching that rekarm, that did it.
Thanks for the insight kimbert, i definitely need to read more on namespaces. Thanks again for your time guys. |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Wed Feb 08, 2012 2:28 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
paustin_ours wrote: |
Thanks for catching that rekarm, that did it.
Thanks for the insight kimbert, i definitely need to read more on namespaces. Thanks again for your time guys. |
The most important thing is that
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ...>
and
<NS1:Envelope xmlns:NS1="http://schemas.xmlsoap.org/soap/envelope/" ...>
is the same object.
soapenv and NS1 is just alias points to namespace "http://schemas.xmlsoap.org/soap/envelope/".
It doesn't matter how you name namespace alias in most cases.
I saw excaptions. _________________ Marcin |
|
Back to top |
|
 |
|