Author |
Message
|
broker_new |
Posted: Wed Jan 13, 2010 9:34 pm Post subject: WMBv6.1->HTTP GET Messages |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
Hi Guys,
I have exposed a message flow to receive the HTTP GET messages.
The data is posted as follows
http://{HostName}/:7080/SubmitOrderSvc?User=XXX?Password=XXX&Payload=%3C%3Fxml%20version%3D%221.0%22%3F%3E...........
I am reading the message as BLOB but not able to decode it back to XML?
Is there any way that we can cast it to XML?
i used Java Compute Node to decode it back to XML but as ESQL is more efficient i am posting it as a separate thread. x |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jan 14, 2010 1:49 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
CAST is for converting between two simple data types, so is probably not what you need.
Are you asking how to convert a BLOB to a message tree using ESQL?
If so, you need a CREATE statement with PARSE and DOMAIN clauses. There are plenty of examples on the forum. Domain will be XMLNSC, of course. |
|
Back to top |
|
 |
mgk |
Posted: Thu Jan 14, 2010 4:09 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
You may also be interested to know that from 6.1.0.4 and above the HTTPInput node has a property to parse and url-decode a querystring into name-value pairs in the local environment. This will save you having to parse the querystring by hand. You will still need to use CREATE with PARSE as kimbert suggests to turn the value into an XMLNSC tree through.
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 |
|
 |
broker_new |
Posted: Thu Jan 14, 2010 8:25 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
let me elaborate more on my problem,
Flow:
HTTPInput>>Compute>>HTTP Reply
On the client side the data is posted as following manner.
http://{HostName}/:7080/SubmitOrderSvc?User=XXX?Password=XXX&Payload=%3C%3Fxml%20version%3D%221.0%22%3F%3E...........
there is no case i read the above data except i read it as BLOB domain.
I cast the input message as Char (CCSID 1208) and REPLACE commands to strip out the "User=XXX?Password=XXX&Payload=" to create an XML message.
Then i parse the message using the CREATE PARSE command or using RCD i can parse it...
But in either of the cases it is not getting parsed because the XML message is encoded, is there a broker capability to decode it back to XML? |
|
Back to top |
|
 |
mgk |
Posted: Thu Jan 14, 2010 9:27 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Quote: |
the XML message is encoded, is there a broker capability to decode it back to XML |
Yes, as I said above:
Quote: |
from 6.1.0.4 and above the HTTPInput node has a property to parse and url-decode a querystring into name-value pairs in the local environment. This will save you having to parse the querystring by hand |
Once you have done this you will have to:
Quote: |
parse the message using the CREATE PARSE command |
To turn it into an XML tree.
Use a trace node to look at the LocalEnvrionment after the httpinput node once that option is checked, to see what I mean.
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 |
|
 |
broker_new |
Posted: Thu Jan 14, 2010 10:13 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
HTTPInput>>Compute>>HTTP Reply
I have set Message Domain as "XMLNSC" and Parse Query String checked ..throwing a parser exception
I tried with Message Domain as "BLOB" but no elements created in LocalEnvironment...am i doing something wrong? |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Jan 14, 2010 10:15 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Quote: |
If so, you need a CREATE statement with PARSE and DOMAIN clauses. There are plenty of examples on the forum. Domain will be XMLNSC, of course. |
This is done in ESQL _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
broker_new |
Posted: Thu Jan 14, 2010 10:20 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
to be specific my question is what domain i have to use it in HTTPInput Node ? it doesn't work either way (XMLNSC, BLOB) |
|
Back to top |
|
 |
mgk |
Posted: Thu Jan 14, 2010 10:57 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Leave the DOMAIN as BLOB in the HTTP Input node. Check the "Parse Query String" property then look at the tree in a trace node. Use a Compute node to do the CREATE PARSE...
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 |
|
 |
broker_new |
Posted: Thu Jan 14, 2010 1:13 pm Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
Doesn't work for me.
I have set "BLOB" and checked the option "Parse Query String".
Nothing was created in OutputLocaEnvironment tree.
ESQL:
DECLARE bodyBlob1 BLOB InputRoot.BLOB.BLOB;
DECLARE creationPtr1 REFERENCE TO OutputRoot;
CREATE LASTCHILD OF creationPtr1 DOMAIN('XMLNSC')
PARSE(bodyBlob1,InputRoot.Properties.Encoding,InputRoot.Properties.CodedCharSetId);
Exception:
Caught exception and rethrowing Error detected, rethrowing
Procedures.XXXXX_MsgFlow_Compute.Main 22.3 RETURN TRUE; XML Parsing Errors have occurred An XML parsing error has occurred while parsing the XML document 1504 2 1 1 An invalid XML character (Unicode: 0x3f) was found in the prolog of the document. /Root/XMLNSC
Here is the POST message:
http://{HostName}:7080/PostSvc1?User=abcd&Password=abcd&Input=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E |
|
Back to top |
|
 |
mgk |
Posted: Thu Jan 14, 2010 2:49 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Did you look at the LocalEnvrionment in a TraceNode? If you do you should see that your url-decoded querystring is in the LocalEnvironment. You never need to use the BLOB message in this case as the contents of the BLOB is parsed out into name-value pairs that are placed into the LocalEnvrionment!
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 |
|
 |
broker_new |
Posted: Fri Jan 15, 2010 7:55 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
unfortunately, i see only the Request identifier
( ['MQROOT' : 0x791a8c0]
(0x01000000:Name):Destination = (
(0x01000000:Name):HTTP = (
(0x03000000:NameValue):RequestIdentifier = X'414d5120574d42363131514d202020203884504b2000a303' (BLOB)
) |
|
Back to top |
|
 |
broker_new |
Posted: Fri Jan 15, 2010 8:08 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
Client code to post the message:
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
public class XmlPost {
public XmlPost() {
}
public static void main(String[] args) {
String postUrl ="http://localhost:7080/PostSvc";
try
{
URL url = new URL( postUrl );
URLConnection postCon = url.openConnection();
postCon.setDoInput(true);
postCon.setDoOutput(true);
postCon.setUseCaches(false);
postCon.setDefaultUseCaches(false);
OutputStreamWriter writer = new OutputStreamWriter( postCon.getOutputStream() );
writer.write( buildXmlRequest().toString());
writer.flush();
writer.close();
InputStreamReader reader = new InputStreamReader( postCon.getInputStream() );
StringBuilder buf = new StringBuilder();
char[] cbuf = new char[ 2048 ];
int num;
while ( -1 != (num=reader.read( cbuf )))
{
buf.append( cbuf, 0, num );
}
String result = buf.toString();
System.out.println( "\nWebservice Response:\n" + result );
}
catch( Throwable t )
{
t.printStackTrace( System.out );
}
}
public static String buildXmlRequest() {
StringBuffer sb = new StringBuffer();
String msg = "?User=abcd&Password=abcd&Input=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E";
System.out.println("\n Webservice XML Request:\n" + msg + "\n");
return msg.toString();
}
} |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jan 15, 2010 8:56 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
broker_new wrote: |
unfortunately, i see only the Request identifier |
Are you using 6.1.0.4?
Did you check the box on the HTTPInput node that mgk mentioned, and redeploy? |
|
Back to top |
|
 |
broker_new |
Posted: Fri Jan 15, 2010 9:13 am Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
C:\IBM\MQSI\6.1>mqsiservice -v
BIPv610 en US
ucnv Console CCSID 437 dft ucnv CCSID 5348
ICUW ibm-5348_P100-1997 ICUA ibm-5348_P100-1997
BIP8996I: Version: 6105
BIP8997I: Product: WebSphere Message Brokers
BIP8998I: CMVC Level: S610-FP05 DH610-FP05
BIP8999I: Build Type: Production
BIP8071I: Successful command completion.
Yes, i followed her steps one by one..
HTTPInput Properties:
Message Domain = BLOB
Checked Parse Query String
Parsed the XML using CREATE PARSE i attached the trace between HTTP Input and Compute ...couldn't find anything |
|
Back to top |
|
 |
|