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 » HTTP Request Node / Post request

Post new topic  Reply to topic
 HTTP Request Node / Post request « View previous topic :: View next topic » 
Author Message
birger.r
PostPosted: Thu Sep 25, 2014 7:35 am    Post subject: HTTP Request Node / Post request Reply with quote

Novice

Joined: 22 Jun 2010
Posts: 10

Hi all,

I am trying to invoke a REST-ful API by using the HTTP Request Node. I am using WMB 8.0.0.4 on RHEL.

I need to send POST data to this service, but it appears I am not able to do it.

My code looks as follows:

FLOW: MQ Input -> Compute -> HTTP Request -> Compute -> MQ Output
(Compute mode = Local Environment and Message)

ESQL-snippet of first copute node
Code:

SET OutputLocalEnvironment.Destination.HTTP.RequestLine.Method = 'POST';
Set OutputRoot.HTTPRequestHeader."Content-Type" = 'application/x-www-form-urlencoded';
SET OutputLocalEnvironment.Destination.HTTP.QueryString.key1 = "value1"; -- Multiple key values pairs are set in the code
SET OutputLocalEnvironment.Destination.HTTP.RequestURL = requestURL;


If I am checking what is sent by message broker, I can see all key-value pairs are sent, but not as POST parameter, but as part of the query. The web service I am trying to invoke needs the parameters as Part of the POST request, not as part of the Query- String. Any chance to get this working?

I am using requestb.in to check my HTTP-Requests - if that is of any help.

I have tried to set the POST data as body of the message (as BLOB) - I can see this is sent as Body, but this does not help, too.

Any hint is highly appreciated.

Cheers, Birger.
Back to top
View user's profile Send private message
Tibor
PostPosted: Thu Sep 25, 2014 7:44 am    Post subject: Reply with quote

Grand Master

Joined: 20 May 2001
Posts: 1033
Location: Hungary

Maybe a dumb question, but did you set the LocalEnviroment tree for propagation?
Back to top
View user's profile Send private message
birger.r
PostPosted: Thu Sep 25, 2014 7:49 am    Post subject: Reply with quote

Novice

Joined: 22 Jun 2010
Posts: 10

Yes - I can see that the settings are set and the key-value pairs exist at the receiving site. But their are set at the wrong place. (They are part of the query, but not part of the POST data.)
Back to top
View user's profile Send private message
Tibor
PostPosted: Fri Sep 26, 2014 1:45 am    Post subject: Reply with quote

Grand Master

Joined: 20 May 2001
Posts: 1033
Location: Hungary

It is very interesting, because HTTPRequest should use POST as a default method by the manual.

Is there any other option for checking your request? Perhaps you could start message flow with an HTTPInput and a Trace node.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Sep 26, 2014 4:43 am    Post subject: Re: HTTP Request Node / Post request Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

birger.r wrote:

I have tried to set the POST data as body of the message (as BLOB) - I can see this is sent as Body, but this does not help, too.

Any hint is highly appreciated.

Cheers, Birger.

Did you try to send it as part of the body as XML as well?
What was the content of your BLOB?

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Fri Sep 26, 2014 5:13 am    Post subject: Re: HTTP Request Node / Post request Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Can someone remind me of what this is supposed to do?

Code:
Set OutputRoot.HTTPRequestHeader."Content-Type" = 'application/x-www-form-urlencoded';


I've forgotten some of my niceties of HTTP rules.
Back to top
View user's profile Send private message
akil
PostPosted: Sun Oct 26, 2014 9:13 am    Post subject: Reply with quote

Partisan

Joined: 27 May 2014
Posts: 338
Location: Mumbai

application/x-www-form-urlencoded encodes the name value pairs as a query string in the POST body.

Something like the following

Code:

POST /test/demo_form.asp HTTP/1.1
Host: w3schools.com
name1=value1&name2=value2


Note the key-value pairs are like a query-string..(url encoded)
_________________
Regards
Back to top
View user's profile Send private message Visit poster's website
mgk
PostPosted: Sun Oct 26, 2014 10:54 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1638

WMB/IIB does not currently help when constructing 'application/x-www-form-urlencoded' messages. You will need to construct the message using the BLOB parser. Please raise a requirement if you think this would be useful...

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
Cubersome
PostPosted: Tue May 19, 2015 7:51 am    Post subject: Reply with quote

Apprentice

Joined: 02 Mar 2012
Posts: 37

Hi Mgk,
Could you please let me know is the following requirement possible in WMB 8.0.0.4
Requriement Details:
--------------------------
I want to send large payload as part of the HTTP POST and as a QueryString but not in the URL.
I want something like
HTTP POST http://ABC URL
content type - 'application/x-www-form-urlencoded';
Then entire query string as part of the body. Not along with the URL

Currently HTTP Request node with POST is sending as
http://ABC URL?key1=value

I want key1= value as part of the body but as a query string.
In SOAP UI we have a check box option for HTTP Test Request to post the QueryString parameters as part of the body. Can the same behavior available in WMB?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed May 20, 2015 4:46 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Reopening quite an old post here...
Did you try following mgk's advice and post the information not as a query string but URL encode it and post it as a BLOB?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Cubersome
PostPosted: Wed May 20, 2015 5:11 am    Post subject: Reply with quote

Apprentice

Joined: 02 Mar 2012
Posts: 37

Hi fjb_super,

The first thing I have done is posting the body as BLOB but the receiving application is not able to intercept the message because of XML special characters. When I am sending the data as QueryString it is able to intercept the message correctly with XML special characters.
When the payload is too big all the data is going with the URL and we do have some length constraints set for the HTTP header size.

So that's the reason I am trying to send the payload as Query String as part of the body.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed May 20, 2015 5:21 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

well the thing is you have to URL encode it first. Just sending the query string as blob apparently won't do it... Best suited for URL encoding would probably be a java compute node or a static java function with an ESQL call out ...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Cubersome
PostPosted: Wed May 20, 2015 5:46 am    Post subject: Reply with quote

Apprentice

Joined: 02 Mar 2012
Posts: 37

Hi fjb_saper,
Below is the detailed explanation:
Code:

      SET aHost = SUBSTRING(SUBSTRING(xxURL AFTER 'http://') BEFORE '/');
      SET aPOST = SUBSTRING(xxURL AFTER aHost) || '?';

       SET OutputRoot.HTTPRequestHeader.POST = aPOST;
       SET OutputRoot.HTTPRequestHeader.Host = aHost;
       SET OutputRoot.HTTPRequestHeader."Content-Type" = 'application/x-www-form-urlencoded';
      SET OutputLocalEnvironment.Destination.HTTP.RequestURL = xxURL; 
SET OutputLocalEnvironment.Destination.HTTP.QueryString.Key = SUBSTRING(ABC_Message  AFTER 'Key=');

In the above case the message populating out of the Compute Node is
Properties,
HTTP Request Header
and Under the Local Environment Query String is getting populated with the entire data.
And if I comment the below line of code:
Code:

--SET OutputLocalEnvironment.Destination.HTTP.QueryString.Key = SUBSTRING(ABC_Message  AFTER 'Key=');
--And sending as
SET OutputRoot.BLOB.BLOB = CAST(cTempMsg AS BLOB CCSID InputRoot.Properties.CodedCharSetId Encoding InputRoot.Properties.Encoding);

In the above case the message populating out of the Compute Node is
Properties,
HTTP Request Header
BLOB with the entire data

So If I put a java compute node or static Java function the data will be encoded but the way it sent out will remains as above.
Please let me know If I am missing anything
Also thanks a lot for your valuable inputs.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed May 20, 2015 6:00 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Cubersome wrote:
The first thing I have done is posting the body as BLOB but the receiving application is not able to intercept the message because of XML special characters. When I am sending the data as QueryString it is able to intercept the message correctly with XML special characters.


And you did not think this problem was due to the fact that your QueryString was not URL encoded when sending it as a BLOB?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » HTTP Request Node / Post request
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.