Author |
Message
|
RK2010 |
Posted: Thu Jul 05, 2012 1:58 am Post subject: Need a solution on HTTP POST Key Value parameters |
|
|
Newbie
Joined: 05 Jul 2012 Posts: 7
|
Hi,
BACKGROUND INFO
- I have an application which will call a web service, via IBM message broker, on a web server. The web service call is a http post with some key-value parameters in it. The servlet in the web server will then use request.getparameter() to retrieve the values. Below is a summary of the above description.
APP --- Message Broker --- Web server (servlet)
- The MQ message broker flow is as follows:
Httpinput node – compute 1 node (esql) – Httprequest node – compute 2 node (esql) – Httpreply node.
WHAT HAS BEEN TESTED
- I cannot retrieve the parameters in the web server. If I bypass the message broker, I will be able to retrieve the key-value parameters in the web server.
- I am now trying to find out how to set the key-value pairs in "compute 1 node" such that Httprequest node will be able to post the parameters to the web server.
- I understand that the parameters are contained in the InputRoot.BLOB.BLOB and I manage to CAST it to a string. However, I don't know where should I set the string in the message headers such that the Httprequest node will pass it to the web server and the web server will be able to retrieve the values using request.getparameter().
Thanks in advance. |
|
Back to top |
|
 |
mgk |
Posted: Thu Jul 05, 2012 2:30 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
|
Back to top |
|
 |
RK2010 |
Posted: Thu Jul 05, 2012 6:17 am Post subject: |
|
|
Newbie
Joined: 05 Jul 2012 Posts: 7
|
Hi mgk,
Thanks for your reply. I have read through the httprequest node information. However, I still do not know how to set the parameters using the Esql before the httprequest node makes the request. I am pretty new to Esql and therefore appreciate if you can elaborate more.
Thank you so much. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Thu Jul 05, 2012 6:19 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Why are you not using SOAP nodes?
Please post (in [c o d e ] tags) examples of your request and reply. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mgk |
Posted: Thu Jul 05, 2012 6:25 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Did you read the QueryString section?
Quote: |
Allows the setting of outbound query string parameters. Each parameter must be set individually. For example:
Code: |
SET OutputLocalEnvironment.Destination.HTTP.QueryString.param1 = 'my"Value"1';
SET OutputLocalEnvironment.Destination.HTTP.QueryString.param2 = 'my"Value"2'; |
The above ESQL results in the following query string being encoded (according to http://tools.ietf.org/html/rfc3986) and sent with the outbound request:
Code: |
?param1=my%22Value%221¶m2= my%22Value%222 |
If the destination URL already has one or more query parameters, additional parameters specified here are appended to the existing list. |
Quote: |
Why are you not using SOAP nodes? |
Well as he is trying to use a QueryString he is probably calling a REST type service....
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 |
|
 |
RK2010 |
Posted: Thu Jul 05, 2012 6:31 am Post subject: |
|
|
Newbie
Joined: 05 Jul 2012 Posts: 7
|
Hi,
Thanks for the question.
Because I am not using soap to call the web service. I am just calling an URL & it will return me an XML. I am not using the soap protocol. |
|
Back to top |
|
 |
RK2010 |
Posted: Thu Jul 05, 2012 6:42 am Post subject: |
|
|
Newbie
Joined: 05 Jul 2012 Posts: 7
|
Hi mgk,
Yes. You are right. I am calling a REST service type.
Yes, I did read about the query string. So, am i right to say that i must find out the no. Of key value pairs in the given URL & set it individually, as shown in the example?
Is there any other way, without finding the number of key pair values? As my number of key pairs may vary.
Thanks a lot... |
|
Back to top |
|
 |
mgk |
Posted: Thu Jul 05, 2012 6:50 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
No, you do not need to know the number in advance - you just create as many name-value pairs as you need. This can vary per message if necessary... Try it and see how it works...
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 |
|
 |
RK2010 |
Posted: Thu Jul 05, 2012 7:00 am Post subject: |
|
|
Newbie
Joined: 05 Jul 2012 Posts: 7
|
Hi mgk,
Got it. I will try to set the key-value pairs individuallyfirst.
Thanks for your help.
Thanks lancelotlinc too. |
|
Back to top |
|
 |
RK2010 |
Posted: Thu Jul 05, 2012 7:38 pm Post subject: |
|
|
Newbie
Joined: 05 Jul 2012 Posts: 7
|
Hi,
I am trying to pass the parameter: key=value1.
I have tried using the following esql, as highlighted by mgk.
SET OutputLocalEnvironment.Destination.HTTP.QueryString.key = 'value1';
However, my servlet still cannot receive the parameters or the key-pair values.
Has anyone tried this before? Does it work?
Or must I do anything to the HttpRequest node for it to recognise the parameters?
Appreciate if someone can guide me on how to debug this issue.
Thanks. |
|
Back to top |
|
 |
McueMart |
Posted: Fri Jul 06, 2012 12:04 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
Have you set the correct Compute mode on your Compute node? Hint: LocalEnvironment needs to be propagated. |
|
Back to top |
|
 |
RK2010 |
Posted: Fri Jul 06, 2012 2:59 am Post subject: |
|
|
Newbie
Joined: 05 Jul 2012 Posts: 7
|
Hi McueMart,
Yes. I have changed the compute mode to "LocalEnvironment and Message". As for my HttpRequest node, I have checked all in the Advanced properties.
Below is my compute node code:
---------------------------------------------------------------------------------
DECLARE finalDestinationUrl CHAR;
DECLARE inputUrl CHAR;
DECLARE requestMethod CHAR;
DECLARE parameters CHAR;
SET inputUrl = InputRoot.HTTPInputHeader."X-Original-HTTP-Command";
SET requestMethod = SUBSTRING(inputUrl BEFORE ' http://');
SET inputUrl = SUBSTRING(inputUrl BEFORE ' HTTP/');
SET finalDestinationUrl = 'http://' || DestinationIP || SUBSTRING(inputUrl AFTER '7080');
SET OutputRoot.HTTPRequestHeader."X-Original-HTTP-URL" = finalDestinationUrl;
SET OutputLocalEnvironment.Destination.HTTP.RequestLine.Method = requestMethod;
SET OutputLocalEnvironment.Destination.HTTP.QueryString.key = 'value1';
RETURN TRUE;
----------------------------------------------------------------------------
Is this correct? Thanks in advance. |
|
Back to top |
|
 |
mgk |
Posted: Fri Jul 06, 2012 3:20 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
The code looks ok, but I would use:
Code: |
OutputLocalEnvironment.Destination.HTTP.RequestURL |
To set the destination rather than the X-Original-HTTP. Also use an HTTP tool to see what was sent on the wire - "fiddler", "nettool" and the monitor that come with the toolkit can all be used to see what was actually sent. Also, you could try just hard coding the URL with the query string just to see if the remote end can see that then work backwards once you have something working to add in the dynamic logic bit by bit...
Quote: |
Has anyone tried this before?? |
yes
yes - assuming you are on a recent enough version of WMB. I think the query string support went in around 6.1.0.4...
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 |
|
 |
|