|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
HTTP Client IIB9 |
« View previous topic :: View next topic » |
Author |
Message
|
sleepyjamie |
Posted: Fri Jul 31, 2015 12:18 pm Post subject: HTTP Client IIB9 |
|
|
Centurion
Joined: 29 Apr 2015 Posts: 135
|
I'm trying to set the HTTP Headers in a Java Compute node. I've found documentation for it, however it is all shown in ESQL.
I'm in the process of learning the IIB Java API. Here is what I am trying to do:
SET OutputRoot.HTTPRequestHeader."Content-Type" = 'application/json';
SET OutputRoot.HTTPRequestHeader."Authorization" = 'key=abc';
SET OutputRoot.JSON = "" |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Jul 31, 2015 12:21 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
sleepyjamie |
Posted: Fri Jul 31, 2015 12:32 pm Post subject: |
|
|
Centurion
Joined: 29 Apr 2015 Posts: 135
|
Thanks.
MbElement elRoot = outMessage.getRootElement();
MbElement elHttpRequestHeader = elRoot.createElementAsLastChild(MbElement.TYPE_NAME, "HTTPRequestHeader", null);
elHttpRequestHeader.createElementAfter(MbElement.TYPE_NAME_VALUE, "Authorization", "key=ABC");
elHttpRequestHeader.createElementAfter(MbElement.TYPE_NAME_VALUE, "Content-Type", "application/json");
MbElement body = outMessage.getRootElement().getFirstElementByPath("BLOB");
body.setValue("{\"to\":\"/topics/test\",\"data\":{\"message\":\"Test message from IIB\"}}"); |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jul 31, 2015 1:33 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
sleepyjamie wrote: |
Thanks.
MbElement elRoot = outMessage.getRootElement();
MbElement elHttpRequestHeader = elRoot.createElementAsLastChild(MbElement.TYPE_NAME, "HTTPRequestHeader", null);
elHttpRequestHeader.createElementAfter(MbElement.TYPE_NAME_VALUE, "Authorization", "key=ABC");
elHttpRequestHeader.createElementAfter(MbElement.TYPE_NAME_VALUE, "Content-Type", "application/json");
MbElement body = outMessage.getRootElement().getFirstElementByPath("BLOB");
body.setValue("{\"to\":\"/topics/test\",\"data\":{\"message\":\"Test message from IIB\"}}"); |
Looks like you 're doing it the hard way and missing half of what you should be doing for lack of understanding.
Please try this out first: Use the palette to add an HTTPRequestHeader and set the values you want in the properties.
Then in the subsequent JCN you can explore the InputMessage and HTTPRequestHeader and get a feel for it.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Aug 03, 2015 4:41 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Did you do something to create OutputRoot.BLOB.BLOB first?
Should you be using OutputRoot.JSON instead? |
|
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
|
|
|
|