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 » Need a solution on HTTP POST Key Value parameters

Post new topic  Reply to topic
 Need a solution on HTTP POST Key Value parameters « View previous topic :: View next topic » 
Author Message
RK2010
PostPosted: Thu Jul 05, 2012 1:58 am    Post subject: Need a solution on HTTP POST Key Value parameters Reply with quote

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
View user's profile Send private message
mgk
PostPosted: Thu Jul 05, 2012 2:30 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Yes, look up this link in the docs for the HTTPRequest node:

http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/topic/com.ibm.etools.mft.doc/ac04595_.htm

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
View user's profile Send private message
RK2010
PostPosted: Thu Jul 05, 2012 6:17 am    Post subject: Reply with quote

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
View user's profile Send private message
lancelotlinc
PostPosted: Thu Jul 05, 2012 6:19 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
mgk
PostPosted: Thu Jul 05, 2012 6:25 am    Post subject: Reply with quote

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&param2= 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
View user's profile Send private message
RK2010
PostPosted: Thu Jul 05, 2012 6:31 am    Post subject: Reply with quote

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
View user's profile Send private message
RK2010
PostPosted: Thu Jul 05, 2012 6:42 am    Post subject: Reply with quote

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
View user's profile Send private message
mgk
PostPosted: Thu Jul 05, 2012 6:50 am    Post subject: Reply with quote

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
View user's profile Send private message
RK2010
PostPosted: Thu Jul 05, 2012 7:00 am    Post subject: Reply with quote

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
View user's profile Send private message
RK2010
PostPosted: Thu Jul 05, 2012 7:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
McueMart
PostPosted: Fri Jul 06, 2012 12:04 am    Post subject: Reply with quote

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
View user's profile Send private message
RK2010
PostPosted: Fri Jul 06, 2012 2:59 am    Post subject: Reply with quote

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
View user's profile Send private message
mgk
PostPosted: Fri Jul 06, 2012 3:20 am    Post subject: Reply with quote

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
Quote:
Does it work?
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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Need a solution on HTTP POST Key Value parameters
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.