ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL for Soap message....

Post new topic  Reply to topic Goto page 1, 2  Next
 ESQL for Soap message.... « View previous topic :: View next topic » 
Author Message
dcapodic
PostPosted: Mon Jan 29, 2007 1:05 pm    Post subject: ESQL for Soap message.... Reply with quote

Apprentice

Joined: 03 Sep 2003
Posts: 32

Hi....

I am trying to create this message in esql:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GenerateDocuments xmlns="http://tempuri.org/DocGenerationWS/WSDocGeneration">
<strXMLString>string</strXMLString>
</GenerateDocuments>
</soap:Body>
</soap:Envelope>

I am having trouble with this part:
<GenerateDocuments xmlns="http://tempuri.org/DocGenerationWS/WSDocGeneration">

My esql for the remainder is:

DECLARE mySoapNS NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
DECLARE myNS1 NAMESPACE 'http://www.tempuri.docgenerationws.wsdocgeneration';
DECLARE xsi NAMESPACE 'http://www.w3.org/2001/XMLSchema-instance';
DECLARE xsd NAMESPACE 'http://www.w3.org/2001/XMLSchema';


SET OutputRoot.XMLNS.mySoapNS:Envelope.(XML.NamespaceDecl)xmlns:xsi = 'http://www.w3.org/2001/XMLSchema-instance';
SET OutputRoot.XMLNS.mySoapNS:Envelope.(XML.NamespaceDecl)xmlns:xsd = 'http://www.w3.org/2001/XMLSchema';
SET OutputRoot.XMLNS.mySoapNS:Envelope.(XML.NamespaceDecl)xmlns:soap = 'http://schemas.xmlsoap.org/soap/envelope/';

--problem spot--

SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.GenerateDocuments.strXMLString = InputRoot.XML;

Any ideas would be welcomed

Thanks....
Dan
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jan 29, 2007 1:30 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

The element 'GenerateDocuments' has a 'default namespace'. In other words, it does have a namespace, but its prefix is the empty string.
So when you create it in the message tree, you need to give it the correct namespace. Like this:
Code:
SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS1:GenerateDocuments.strXMLString = InputRoot.XML;

If you want your output message to look like your example, you need to create xmlns attributes in the message tree. The XMLNS serializer will detect them and use them to output your chosen prefixes. Read this topic to see how to do it : http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/topic/com.ibm.etools.mft.doc/ac17330_.htm
Back to top
View user's profile Send private message
dcapodic
PostPosted: Mon Jan 29, 2007 2:26 pm    Post subject: Reply with quote

Apprentice

Joined: 03 Sep 2003
Posts: 32

Hmmm....

By the explanantion in that topic, this should work:

SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.GenerateDocuments.(XML.NamespaceDecl)xmlns = 'http://tempuri.org/DocGenerationWS/WSDocGeneration';

....but it does not. It fails. It states that "GenerateDocumnets" is not part of a namespace definition....So I am a bit confused by that topic description.
Back to top
View user's profile Send private message
madi
PostPosted: Mon Jan 29, 2007 2:39 pm    Post subject: Reply with quote

Chevalier

Joined: 17 Jan 2006
Posts: 475

dcapodic wrote:
Hmmm....

By the explanantion in that topic, this should work:

SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.GenerateDocuments.(XML.NamespaceDecl)xmlns = 'http://tempuri.org/DocGenerationWS/WSDocGeneration';

....but it does not. It fails. It states that "GenerateDocumnets" is not part of a namespace definition....So I am a bit confused by that topic description.


it will not work like that unless you are doing it for the root element.

i tried it in a lot of ways but no use the only u will get it is with a namespace prefix

--madi
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jan 29, 2007 2:44 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

madi : Sorry, but you're wrong. XMLNS can do this. You need to re-read the XML spec and then understand how XMLNS handles namespaces and namespace prefixes ( which are not the same thing, by the way ).

dcapodic: I think you missed the important part of my previous post. Here it is again, highlighted this time:

SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS1:GenerateDocuments.strXMLString = InputRoot.XML;
Back to top
View user's profile Send private message
madi
PostPosted: Mon Jan 29, 2007 3:09 pm    Post subject: Reply with quote

Chevalier

Joined: 17 Jan 2006
Posts: 475

Quote:
SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS1:GenerateDocuments.strXMLString = InputRoot.XML;


doesn't this mean that GenerateDocuments is gettign the myNS1 prefix??

--madi
Back to top
View user's profile Send private message
dcapodic
PostPosted: Mon Jan 29, 2007 9:39 pm    Post subject: Reply with quote

Apprentice

Joined: 03 Sep 2003
Posts: 32

HI again....

Actually, respecfully....this:

SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS1:GenerateDocuments.strXMLString = InputRoot.XML;

does not work. It complains about the element strXMLString. This does work:

SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS1:GenerateDocuments.myNS1:strXMLString = InputRoot.XML;

....but pushes the problem downstream further. You see, the "string" that I need to place into the strXMLString tag is actually an xml message, so it keeps wanting every element to be qualified with a XMLNS namespace declaration. If I just set the strXMLString tag to a literal value like 'haha' it wokrs as I need it. This:

SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS1:GenerateDocuments.(XML.NamespaceDecl)xmlns = 'http://www.tempuri.docgenerationws.wsdocgeneration';
SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.GenerateDocuments.strXMLString = InputRoot.XML;

gets me this xml:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GenerateDocuments xmlns="http://www.tempuri.docgenerationws.wsdocgeneration"/>
<GenerateDocuments>
<strXMLString>....

As you can see, I have 2 "GenerateDocuments" tags. The structure of the first is fine at least and the xml that I am embedding comes out fine, I jus thave 2 tags

Any ideas are again welcome!!

Thanks....
Dan
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Mon Jan 29, 2007 10:49 pm    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi dcapodic,
dcapodic wrote:
SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS1:GenerateDocuments.myNS1:strXMLString = InputRoot.XML;
If its a default namespace, it will apply to all the elements below it, which do not have any other explicitely defined namespace.

I doubt if this is the solution to the problem ur facing, but first things first...

Regards.
Back to top
View user's profile Send private message Send e-mail
dcapodic
PostPosted: Tue Jan 30, 2007 9:56 am    Post subject: Reply with quote

Apprentice

Joined: 03 Sep 2003
Posts: 32

Hi....

elvis....I am not sure what you are saying in your post. If it is that by coding it this way:

SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS1:GenerateDocuments.myNS1:strXMLString = InputRoot.XML;

the default namespace myNS1 should apply to all elements below it then, respecfully (again) you are incorrect. I speak not from any maual but practical usage. I have tried this and it simply does not work, no quesiotns asked The error states that each child element of a parent must have an explicitly defined namespace to it. Now, I agree with you this does not seem to be the way it should work but this is in factg the way it does work. As for the documentation, it is so ambiguous that it is really not helpful.

My guess is I am down the wrong path with trying to do this within the XMLNS domain. But, it gets a bit frustrating when the docs say that this is the root you should take but then it just doesn't work

Thanks....
Dan
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Tue Jan 30, 2007 11:30 am    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

dcapodic wrote:
the default namespace myNS1 should apply to all elements below it then, respecfully (again) you are incorrect. I speak not from any maual but practical usage. I have tried this and it simply does not work, no quesiotns asked The error states that each child element of a parent must have an explicitly defined namespace to it. Now, I agree with you this does not seem to be the way it should work but this is in factg the way it does work. As for the documentation, it is so ambiguous that it is really not helpful.
Now I did not understand what u mean...And I don't even want to comment on your understanding, or ur opinion about mine...ignorance is bliss...

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GenerateDocuments xmlns="http://tempuri.org/DocGenerationWS/WSDocGeneration">
<strXMLString>string</strXMLString>
</GenerateDocuments>
</soap:Body>
</soap:Envelope>

For the above output, u need the code as below...no questions asked.
Code:
CREATE COMPUTE MODULE Test_Compute
   
   DECLARE soap NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
   DECLARE myNS1 NAMESPACE 'http://tempuri.org/DocGenerationWS/WSDocGeneration';

   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
      CALL CopyMessageHeaders();

      CREATE LASTCHILD OF OutputRoot DOMAIN 'XMLNS' NAME 'XMLNS';
      SET OutputRoot.XMLNS.(XML.XmlDecl).(XML.Version) = '1.0';
      SET OutputRoot.XMLNS.(XML.XmlDecl).(XML."Encoding") = 'UTF-8';

      CREATE LASTCHILD OF OutputRoot.XMLNS NAMESPACE soap NAME 'Envelope';
      SET OutputRoot.XMLNS.soap:Envelope.(XML.NamespaceDecl)xmlns:xsi = 'http://www.w3.org/2001/XMLSchema-instance';
      SET OutputRoot.XMLNS.soap:Envelope.(XML.NamespaceDecl)xmlns:xsd = 'http://www.w3.org/2001/XMLSchema';
      SET OutputRoot.XMLNS.soap:Envelope.(XML.NamespaceDecl)xmlns:soap = 'http://schemas.xmlsoap.org/soap/envelope/';      

      SET OutputRoot.XMLNS.soap:Envelope.soap:Body.myNS1:GenerateDocuments.(XML.NamespaceDecl)xmlns = 'http://tempuri.org/DocGenerationWS/WSDocGeneration';
      SET OutputRoot.XMLNS.soap:Envelope.soap:Body.myNS1:GenerateDocuments.myNS1:strXMLString = 'string';

      RETURN TRUE;
   END;

   CREATE PROCEDURE CopyMessageHeaders() BEGIN
      DECLARE I INTEGER;
      DECLARE J INTEGER;
      SET I = 1;
      SET J = CARDINALITY(InputRoot.*[]);
      WHILE I < J DO
         SET OutputRoot.*[I] = InputRoot.*[I];
         SET I = I + 1;
      END WHILE;
   END;
END MODULE;
The code is not tested but did not throw any errors in the toolkit...

You will soon be asked to use XMLNSC...

Regards.
Back to top
View user's profile Send private message Send e-mail
dcapodic
PostPosted: Tue Jan 30, 2007 12:00 pm    Post subject: Reply with quote

Apprentice

Joined: 03 Sep 2003
Posts: 32

HI....

First off, thanks for the help elvis! I do offer any commentary otehr than what is factual or not which is why I try EVERYTHING before I ask or comment about it. As I stated earleir in the thread, you are right this:

This does work:

SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS1:GenerateDocuments.myNS1:strXMLString = InputRoot.XML;

will work, as long as the contents of the InputRoot.XML is literally string data. Mine happens to be an xml message taht I am trying to place in the tag strXMLString. When I do this, errors are kicked stating that the xml elements in the "string" payload are not associated with a namespace. This is why I questioned you about what you ahd said earlier. It seems that the child elements DO NOT inherit the default namespace, in this case myNS1.

Sorry if I am not being clear. It would seem the only way I can accomplish what I am trying to do is to declare a namespace for every element of the embedded xml string. I have not tried this but was certainly hoping this would not have to be done. I will then also have to parse the incoming xml piece by piece, whereas I was hoping to grab it whole and simply drop it in the strXMLString tag. This is the first time I am trying something like this in the messagee broker but this is common to do in code.

Thanks for your help and time!
Dan
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Tue Jan 30, 2007 12:20 pm    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi dcapodic,

Ok, I think I understand your problem, instead of this
dcapodic wrote:
SET OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS1:GenerateDocuments.myNS1:strXMLString = InputRoot.XML;
Try this
Code:
CREATE FIELD OutputRoot.XMLNS.mySoapNS:Envelope.mySoapNS:Body.myNS1:GenerateDocuments.myNS1:strXMLString FROM InputRoot.XML;

Regards.
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Tue Jan 30, 2007 2:24 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Hi all,

Everybody gets confused about XML namespace prefixes, so here are the facts:

In an XML document
A. The name of any element or attribute can be qualified by a namespace URI.
Like this: <http://com.ibm.wmb.namespaceTutorial:elementName />
B. Namespace URIs are often long, so you can define a shorter string which replaces the namespace. This is called a namespace prefix and it is defined using a special XML attribute called a namespace declaration.
<ns1:elementName xmlns:ns1="http://com.ibm.wmb.namespaceTutorial" />
C. You can even allocate a zero-length namespace prefix for a namespace URI. If you do, that namespace URI becomes the 'default namespace', and any element without a prefix will have that namespace.
<elementName xmlns="http://com.ibm.wmb.namespaceTutorial" />
Note: elementName still has the namespace 'http://com.ibm.wmb.namespaceTutorial'.

In the message tree
1. The name of an element can be qualified by a namespace URI.
SET OutputRoot.{http://com.ibm.wmb.namespaceTutorial}:elementName = "string";
2. Namespace URIs are usually long, so you can define a shorter string which replaces the namespace in your ESQL paths. This is called a namespace constant.
DECLARE myNS NAMESPACE 'http://com.ibm.wmb.namespaceTutorial';
SET OutputRoot.myNS:elementName = "string";
A namespace constant allows you to write shorter and more readable paths in your ESQL. An ESQL namespace constant is not a namespace prefix, and it does not control the namespace prefix allocated by the parser when it outputs the message tree.
3. You can control the prefixes which the parser uses on output. This is done by putting namespace declarations into the message tree ( see B. above ). There are examples of this in the docs, and in this thread.

I'm going to write an article about this sometime. For now, I hope this helps.
Back to top
View user's profile Send private message
pathipati
PostPosted: Tue Jan 30, 2007 2:32 pm    Post subject: Reply with quote

Master

Joined: 03 Mar 2006
Posts: 296

good job Kimbert, this really helps...
Back to top
View user's profile Send private message Yahoo Messenger
dcapodic
PostPosted: Tue Jan 30, 2007 9:02 pm    Post subject: Reply with quote

Apprentice

Joined: 03 Sep 2003
Posts: 32

Hi....

elvis....thanks for the suggestion but it fails with the same issues as with the previous esql....all elements of the stringXMLString must also be qualified with a namespace.

Kimbert....the info you gave is helpful but should really be a bit more detailed. The most important ommision would be the fact that once you qualify an element with a namespace, all children of that element must also be qualified....and (this is what is biting me) this includes any InputRoot data being assigned to this element.

I confess to most of my experience being practical....I write code and experiment to see how things ACTUALLY work. I am familiar with the specs on how namespaces should work where my understanding fell short in this case was on how the XMLNS parser used in WMBIB v6 would handle this. This particular limitation I believe makes what I am attempting to do impossible, yet it is extremely easy to do in code. I haven't thrown in the towel yet but I must admit to having spent far more time on this than I ever would have imagined

I am not/nor would ever ask you to write the code for me but if you look at the earlier posts, does it sem like what I am attempting to do should be possible? You seem to have a robust knowledge of this subject so if I am down the wrong path feel free to knock me off it

Thanks....
Dan
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL for Soap message....
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.