|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Message Broker, HTTP Request and HTTP POST |
« View previous topic :: View next topic » |
Author |
Message
|
mqmqmq |
Posted: Thu Feb 05, 2009 2:04 am Post subject: Message Broker, HTTP Request and HTTP POST |
|
|
Novice
Joined: 02 Jul 2008 Posts: 22
|
Hi all,
I have Broker v6.0. I should send data with HTTP POST method to target system (outside our company's network). Target system has a servlet, which should be called with POST method with couple of parameters.
The syntax of the call is: https://www.domain.xxx.com/servlet/XxxDataRcv
I'm using HTTPRequest Node to do this, but without success so far.
When I test the target service with IE, the target system works. In IE I put the following line to address bar:
https://www.domain.com/servlet/XxxData?p1=aa&p2=bb&p3=cc
The target system replies with text string.
Does anyone have short (and perhaps working) example code which I should put in Compute node before HTTPRequest node?
Thanks!
BR,
--
mqmqmq |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Feb 05, 2009 2:29 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It's usually more useful in getting answers to post details of what "without success" means - that is, to show an appropriately trimmed piece of data that demonstrates the failure.
I am *guessing* that you are trying, and failing, to get the POST to send data using URL Encoding of parameters - the "?&p1=aa". I know there are mechanisms for doing this with HTTP_Request, but I do not remember where (nor care to search for) the documentation on doing it.
Of course it could also be that your Broker does not have network layer access to the external HTTP server in the first place. - but without some idea of how things are failing, I can't say. |
|
Back to top |
|
 |
Esa |
Posted: Thu Feb 05, 2009 3:19 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
|
Back to top |
|
 |
mqmqmq |
Posted: Thu Feb 05, 2009 3:52 am Post subject: |
|
|
Novice
Joined: 02 Jul 2008 Posts: 22
|
Hi,
Here is a little more details about the matter.
Yes, the test with IE uses HTTP GET, but it seems to work with that also.
I should transfer the data to servlet via HTTPServletRequest (as parameters in HTTPServletRequest). Is that possible with Broker (I think that in JavaCompute node it is possible, but how about eSQL)?
Posting a form is easy for example with html page.
Code: |
<form method="POST">
...
|
The external access is ok from the Broker server.
In another project I use the code below and it works (target is inside our company's network).
Code: |
SET OutputLocalEnvironment.Destination.HTTP.RequestLine.Method = 'GET';
SET OutputLocalEnvironment.Destination.HTTP.RequestURL = 'http://www.insidedomain.com/xxxapi/xxxapi/login?user=xxx&pwd=yyy';
|
In this "servlet and POST" case I have used the following ways:
#1 (compute node before HTTPRequest node).
Code: |
CALL CopyMessageHeaders();
SET OutputLocalEnvironment.Destination.HTTP.RequestURL = 'http://www.domain.xxx.com/servlet/XxxDataRcv?p1=test1&p2=test2&p3=test3&p4=test4';
RETURN TRUE;
|
Message domain of the HTTPRequest node is set to BLOB (target system replies with text).
Trace (${Root} ${LocalEnvironment}) before HTTPRequest node is:
Code: |
(
(0x01000000):Properties = (
(0x03000000):MessageSet = ''
(0x03000000):MessageType = ''
(0x03000000):MessageFormat = ''
(0x03000000):Encoding = 546
(0x03000000):CodedCharSetId = 437
(0x03000000):Transactional = TRUE
(0x03000000):Persistence = FALSE
(0x03000000):CreationTime = GMTTIMESTAMP '2009-02-05 11:00:38.940'
(0x03000000):ExpirationTime = -1
(0x03000000):Priority = 0
(0x03000000):ReplyIdentifier = X'000000000000000000000000000000000000000000000000'
(0x03000000):ReplyProtocol = 'MQ'
(0x03000000):Topic = NULL
(0x03000000):ContentType = ''
)
(0x01000000):MQMD = (
(0x03000000):SourceQueue = 'Q1.OUT'
(0x03000000):Transactional = TRUE
(0x03000000):Encoding = 546
(0x03000000):CodedCharSetId = 437
(0x03000000):Format = ' '
(0x03000000):Version = 2
(0x03000000):Report = 0
(0x03000000):MsgType = 8
(0x03000000):Expiry = -1
(0x03000000):Feedback = 0
(0x03000000):Priority = 0
(0x03000000):Persistence = 0
(0x03000000):MsgId = X'414d512046494b43495f44312020202052e7c04811690720'
(0x03000000):CorrelId = X'000000000000000000000000000000000000000000000000'
(0x03000000):BackoutCount = 0
(0x03000000):ReplyToQ = ' '
(0x03000000):ReplyToQMgr = 'QM1 '
(0x03000000):UserIdentifier = 'mqm '
(0x03000000):AccountingToken = X'160105150000007f7244136562c2aac6ebb12fed03000000000000000000000b'
(0x03000000):ApplIdentityData = ' '
(0x03000000):PutApplType = 11
(0x03000000):PutApplName = 'C:\IBM\rfhutil\rfhutilc.exe'
(0x03000000):PutDate = DATE '2009-02-05'
(0x03000000):PutTime = GMTTIME '11:00:38.940'
(0x03000000):ApplOriginData = ' '
(0x03000000):GroupId = X'000000000000000000000000000000000000000000000000'
(0x03000000):MsgSeqNumber = 1
(0x03000000):Offset = 0
(0x03000000):MsgFlags = 0
(0x03000000):OriginalLength = -1
)
)
(
(0x01000000):Destination = (
(0x01000000):HTTP = (
(0x03000000):RequestURL = 'http://www.domain.xxx.com/servlet/XxxDataRcv?p1=test1&p2=test2&p3=test3&p4=test4'
)
)
)
|
#2 (compute node before HTTPRequest node)
Code: |
CALL CopyMessageHeaders();
DECLARE p1 CHAR ''; DECLARE p2 CHAR ''; DECLARE p3 CHAR ''; DECLARE p4 CHAR '';
DECLARE cTotalString CHAR '';
SET p1 = 'p1=test1';
SET p2 = '&p2=test2';
SET p3 = '&p3=test3';
SET p4 = '&p4=test4';
SET cTotalString = p1 || p2 || p3|| p4;
SET OutputRoot.HTTPRequestHeader.POST = '/servlet/XxxDataRcv?';
SET OutputRoot.HTTPRequestHeader.Host = 'www.domain.xxx.com';
SET OutputRoot.HTTPRequestHeader."Content-Type" = 'application/x-www-form-urlencoded';
SET OutputLocalEnvironment.Destination.HTTP.RequestURL = 'http://www.domain.xxx.com/servlet/XxxDataRcv';
SET OutputRoot.BLOB.BLOB = CAST(cTotalString AS BLOB CCSID InputRoot.MQMD.CodedCharSetId);
RETURN TRUE;
|
Message domain of the HTTPRequest node is set to BLOB (target system replies with text)
Trace (${Root} ${LocalEnvironment}) before HTTPRequest node is:
Code: |
(
(0x01000000):Properties = (
(0x03000000):MessageSet = ''
(0x03000000):MessageType = ''
(0x03000000):MessageFormat = ''
(0x03000000):Encoding = 546
(0x03000000):CodedCharSetId = 437
(0x03000000):Transactional = TRUE
(0x03000000):Persistence = FALSE
(0x03000000):CreationTime = GMTTIMESTAMP '2009-02-05 11:09:05.820'
(0x03000000):ExpirationTime = -1
(0x03000000):Priority = 0
(0x03000000):ReplyIdentifier = X'000000000000000000000000000000000000000000000000'
(0x03000000):ReplyProtocol = 'MQ'
(0x03000000):Topic = NULL
(0x03000000):ContentType = 'application/x-www-form-urlencoded'
)
(0x01000000):MQMD = (
(0x03000000):SourceQueue = 'Q1.OUT'
(0x03000000):Transactional = TRUE
(0x03000000):Encoding = 546
(0x03000000):CodedCharSetId = 437
(0x03000000):Format = 'WSREQHDR'
(0x03000000):Version = 2
(0x03000000):Report = 0
(0x03000000):MsgType = 8
(0x03000000):Expiry = -1
(0x03000000):Feedback = 0
(0x03000000):Priority = 0
(0x03000000):Persistence = 0
(0x03000000):MsgId = X'414d512046494b43495f44312020202052e7c04813690720'
(0x03000000):CorrelId = X'000000000000000000000000000000000000000000000000'
(0x03000000):BackoutCount = 0
(0x03000000):ReplyToQ = ' '
(0x03000000):ReplyToQMgr = 'QM1 '
(0x03000000):UserIdentifier = 'mqm '
(0x03000000):AccountingToken = X'160105150000007f7244136562c2aac6ebb12fed03000000000000000000000b'
(0x03000000):ApplIdentityData = ' '
(0x03000000):PutApplType = 11
(0x03000000):PutApplName = 'C:\IBM\rfhutil\rfhutilc.exe'
(0x03000000):PutDate = DATE '2009-02-05'
(0x03000000):PutTime = GMTTIME '11:09:05.820'
(0x03000000):ApplOriginData = ' '
(0x03000000):GroupId = X'000000000000000000000000000000000000000000000000'
(0x03000000):MsgSeqNumber = 1
(0x03000000):Offset = 0
(0x03000000):MsgFlags = 0
(0x03000000):OriginalLength = -1
)
(0x01000000):HTTPRequestHeader = (
(0x03000000):POST = '/servlet/XxxDataRcv?'
(0x03000000):Host = 'www.domain.xxx.com'
(0x03000000):Content-Type = 'application/x-www-form-urlencoded'
)
(0x01000000):BLOB = (
(0x03000000):BLOB = X'70313d74657374312670323d74657374322670333d74657374332670343d7465737434'
)
)
(
(0x01000000):Destination = (
(0x01000000):HTTP = (
(0x03000000):RequestURL = 'http://www.domain.xxx.com//servlet/XxxDataRcv'
)
)
)
|
In both cases HTTPRequest node timeouts. The error text is:
Code: |
2009-02-05 13:29:04.654757~20125280 RecoverableException BIP3152S: Socket error detected whilst invoking Web service located at host 'www.domain.xxx.com', port 80, path '/servlet/XxxDataRcv'.
This may be a transient error, such as a server not responding, or a symptom of an invalid hostname or port number.
Check that the hostname and port number are valid, and point to a functioning Web service.
2009-02-05 13:29:04.654763~20125280 socketTimeoutException BIP3151S: A socket operation timed out. Operation: '::connect()'. Error Code: 0. Timeout in seconds: 121. Error Text: 'Success'.
A timeout occurred whilst performing a TCP/IP socket operation. This may be a transient error, such as a server is busy or it could be that the server is no longer responding.
See the following messages for information pertaining to this error.
|
Hostnames etc. are ok, because I have copied everything from IE address bar (which worked). In this post's example codes addresses etc. has been changed.
I have also tried with couple of variations in the code, but never got response from the target system.
Thanks! |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Feb 05, 2009 4:18 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Is the response from the target system http or xml?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqmqmq |
Posted: Thu Feb 05, 2009 4:25 am Post subject: |
|
|
Novice
Joined: 02 Jul 2008 Posts: 22
|
Hi,
Response is plain text, not xml. So if I have to choose between http or xml, I would take http:-) |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Feb 05, 2009 4:50 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It's a network issue of some kind. |
|
Back to top |
|
 |
kamy |
Posted: Thu Feb 05, 2009 5:13 am Post subject: |
|
|
Novice
Joined: 26 Oct 2001 Posts: 21
|
Could it be a fire-wall issue...
The Node on which the Msg broker runs has to be opened to let the traffic from the remote host and vice-versa.
One possible explanation that you can access the URL from IE browser is it be routed via your company proxy.
I would work with the N/W engineers to trace/sniff the request to the fire-wall /internet and back. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|