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 » Exception while trying to hit Restful service (Http Node)

Post new topic  Reply to topic Goto page 1, 2  Next
 Exception while trying to hit Restful service (Http Node) « View previous topic :: View next topic » 
Author Message
xtremeinfo
PostPosted: Thu Dec 03, 2015 3:56 am    Post subject: Exception while trying to hit Restful service (Http Node) Reply with quote

Newbie

Joined: 03 Dec 2015
Posts: 9

Hi all

I am new to message broker
Our requirement is to use message broker with MQinput and restful services.

I have a scenario where message is published to queue.
Using Message broker , I have to subscribe the message using MQInput node, and pass the same to Http node which invokes restfull webservice.

I have my restfull service up in local and for testing purpose created a Get method and able to hit below url

Example : https://172.24.139.140:9081/sampleProject/jaxrs/user?userName=kamal

In Broker project, I created MQInput and created schema, created compute node and for timebeing passing the input to output and mapped compute node to HTTP node.

In Http Node , I have above url
When i try to test , I am getting
"A Web Service request has detected a SOCKET error whilst invoking a "

What else do we have to do in order to hit restfull service from broker

I saw couple of questions related to this error and it was mentioned to import certificate, what is that certificate and how can i get it , where can i import it .

Few other said they modified esql code but i dont have any logic except to copy input to output

Also after this error is resolved , I would like to know how i can convert input XML schema to JSON object in eSQL code? does anyone has any sample code?

I am not able to post complete error trace as I have the broker installed in client network.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Dec 03, 2015 5:28 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Talk to the supplier of the rest service.

Get them to explain what certificates and what authentication you need to access their service.

Talk to your broker administrator. Give them the information (and the certificates if you have them) that you got from the rest service team.

Build the correct message to call the REST service.

Set the correct options to cause the HTTP node to use the right values to call the REST service.

Make sure you can actually reach the network address of the REST service from the machine running Broker.

See my signature.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
xtremeinfo
PostPosted: Thu Dec 03, 2015 9:40 am    Post subject: Reply with quote

Newbie

Joined: 03 Dec 2015
Posts: 9

Thanks for the reply.

mqjeff wrote:
Talk to the supplier of the rest service.

Get them to explain what certificates and what authentication you need to access their service.


Actually we have to create our own rest service. is it mandatory to provide certificate for internal access ? can we do with out adding certificates?

If at all its mandatory, is there any option for us to add directly? or only admin team has access?

mqjeff wrote:

Build the correct message to call the REST service.

Set the correct options to cause the HTTP node to use the right values to call the REST service.


what are the options availble to build message for rest service.
I see JSON is available but I do not see to many people implement JSON.
Can anyone pls provide any examples to convert XML to JSON/any other input that is compatible with rest.

mqjeff wrote:

Make sure you can actually reach the network address of the REST service from the machine running Broker.


How can we achieve this ? i.e how to reach restful service from broker ?
I tried to research more but because of short time and other work I am not able to get more information

Thanks in advance.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Dec 03, 2015 9:53 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

xtremeinfo wrote:
Actually we have to create our own rest service. is it mandatory to provide certificate for internal access ? can we do with out adding certificates?


Ask your security people. In your link the URL shows https not http so you've clearly elected to use SSL; we can't know if that's accidental, deliberate, or policy.

xtremeinfo wrote:
If at all its mandatory, is there any option for us to add directly? or only admin team has access?


Ask your admin team. If they put the SSL files in a location to which you have access, you can add them. If they don't, you can't.

xtremeinfo wrote:
what are the options availble to build message for rest service.


The same as for a REST service outside IIB.

xtremeinfo wrote:
I see JSON is available but I do not see to many people implement JSON.


The JSON community will be so disappointed to hear that. If this REST service is internal and you're creating it, you can use JSON, XML, HTTP parameters or (probably) blob data if that's what you think is best.

(Blob data is unlikely to be best IMHO)

xtremeinfo wrote:
Can anyone pls provide any examples to convert XML to JSON/any other input that is compatible with rest.


It's the same as converting any other data structure to any other data structure in IIB. The documentation is filled with examples of all the methods available, as are the samples.

xtremeinfo wrote:
How can we achieve this ? i.e how to reach restful service from broker ?


Make sure the network allows that connection.

xtremeinfo wrote:
I tried to research more but because of short time and other work I am not able to get more information


Then push back on your manager. It's going to be no good for you if you make the deadline with information we provide, hit problems later because we don't have a full understanding of your site standards and requirements, and then you have to explain that you can't fix the problem without going back to the random group of unaccountable strangers on the Internet who suggested the solution originally because you don't really understand what we suggested or all it's implications.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
xtremeinfo
PostPosted: Thu Dec 03, 2015 9:57 pm    Post subject: Reply with quote

Newbie

Joined: 03 Dec 2015
Posts: 9

Vitor wrote:


Ask your security people. In your link the URL shows https not http so you've clearly elected to use SSL; we can't know if that's accidental, deliberate, or policy.


Its accidental , we dont need seperate security configs as its internal
So do we have to create certificate?
I came across few suggestions that we have to configure proxy correct.
what is proxy ? i have provided webservice endpoint as both proxy and webservice url

Vitor wrote:

Ask your admin team. If they put the SSL files in a location to which you have access, you can add them. If they don't, you can't.


we do not have any seperate teams for creating ceritificates or seperate broker admin team . so we have to handle everything..
so any idea how to do these things?
Vitor wrote:

It's the same as converting any other data structure to any other data structure in IIB. The documentation is filled with examples of all the methods available, as are the samples.


Can you please provide link to documentation or step by step guide to invoke restful services

Vitor wrote:
Make sure the network allows that connection.

I tried hitting webservice from browser, so is that it? or anything else to check ?
Back to top
View user's profile Send private message
timber
PostPosted: Fri Dec 04, 2015 1:05 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1292

re: XML to JSON, there is no standard mapping. The obvious first step is
Code:
SET OutputRoot.JSON.Data = InputRoot.XMLNSC;
but that will render everything as a JSON object, which might not be what you need.

http://www.mqseries.net/phpBB/viewtopic.php?t=60835&sid=e646bbc2151bd85957937f528153f2b2

Also, watch out for arrays. If a tag in the XML format can occur more than once then it probably should be rendered as a JSON array. But what happens if ( in a particular input document ) the tag happens to occur exactly once? How will your message flow know that this tag is intended to be rendered as a JSON array?
One solution would be to look in the xsd and detect element declarations that have maxOccurs > 1. But accessing the xsd from within the message flow is very difficult. End result : you have to hard-code the information about the JSON arrays into your message flow.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Dec 04, 2015 5:42 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

xtremeinfo wrote:
Vitor wrote:


Ask your security people. In your link the URL shows https not http so you've clearly elected to use SSL; we can't know if that's accidental, deliberate, or policy.


Its accidental , we dont need seperate security configs as its internal


So use http not https to can it then.

xtremeinfo wrote:
So do we have to create certificate?


Not if you not using SSL.

xtremeinfo wrote:
I came across few suggestions that we have to configure proxy correct.
what is proxy ? i have provided webservice endpoint as both proxy and webservice url


You might have to use a proxy, depending on your network topology and/or SSL use. As you claim you can hit the endpoint and don't want SSL, I would assert you don't need one.

I also find it odd that you ask "what is proxy" and then claim to have provided the endpoint as one.

xtremeinfo wrote:
so any idea how to do these things?


Yes I have. After reading the documentation, you will have to.


xtremeinfo wrote:
Vitor wrote:

It's the same as converting any other data structure to any other data structure in IIB. The documentation is filled with examples of all the methods available, as are the samples.


Can you please provide link to documentation or step by step guide to invoke restful services


The link is the link to the InfoCenter. The step by step guide you want is "how to use IIB", which doesn't fit into a step by step guide.

xtremeinfo wrote:
Vitor wrote:
Make sure the network allows that connection.

I tried hitting webservice from browser, so is that it? or anything else to check ?


Sounds like that's it to me.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
xtremeinfo
PostPosted: Fri Dec 04, 2015 11:03 pm    Post subject: Reply with quote

Newbie

Joined: 03 Dec 2015
Posts: 9

Vitor wrote:


The link is the link to the InfoCenter.


I could not find any link to infocenter . can you please provide me the link
Back to top
View user's profile Send private message
smdavies99
PostPosted: Sat Dec 05, 2015 12:18 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

At the middle/top of the page there is a button called 'Info Center'.
Why not take a trip into the unknown and follow it?

There you will find a wealth of information of IBM products.
When you find the one for your version of the product then bookmark it for future read access.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
xtremeinfo
PostPosted: Sat Dec 05, 2015 7:51 am    Post subject: Reply with quote

Newbie

Joined: 03 Dec 2015
Posts: 9

smdavies99 wrote:
At the middle/top of the page there is a button called 'Info Center'.
Why not take a trip into the unknown and follow it?

There you will find a wealth of information of IBM products.
When you find the one for your version of the product then bookmark it for future read access.


thanks for the info .. will have a look at it
Back to top
View user's profile Send private message
xtremeinfo
PostPosted: Mon Dec 07, 2015 3:55 am    Post subject: Reply with quote

Newbie

Joined: 03 Dec 2015
Posts: 9

timber wrote:
re: XML to JSON, there is no standard mapping. The obvious first step is
Code:
SET OutputRoot.JSON.Data = InputRoot.XMLNSC;
but that will render everything as a JSON object, which might not be what you need.

http://www.mqseries.net/phpBB/viewtopic.php?t=60835&sid=e646bbc2151bd85957937f528153f2b2

Also, watch out for arrays. If a tag in the XML format can occur more than once then it probably should be rendered as a JSON array. But what happens if ( in a particular input document ) the tag happens to occur exactly once? How will your message flow know that this tag is intended to be rendered as a JSON array?
One solution would be to look in the xsd and detect element declarations that have maxOccurs > 1. But accessing the xsd from within the message flow is very difficult. End result : you have to hard-code the information about the JSON arrays into your message flow.


My sample Json will be like

Student {
"id": "0002",
"name": "ram",

}

Can i access in Broker like this in eSQL
SET OutputRoot.JSON.Student.id = InputRoot.XMLNSC.Payload.id

? will this worK?
Student is the root element

and how to set JSON as input to HTTP request?
Back to top
View user's profile Send private message
timber
PostPosted: Mon Dec 07, 2015 5:01 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1292

Quote:
? will this worK?
Have you tried it? If so, what happened?
Quote:
and how to set JSON as input to HTTP request?
Same way you set JSON as input to any other node. Build a JSON message tree and let IIB do the work for you.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Dec 07, 2015 5:03 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

xtremeinfo wrote:
Can i access in Broker like this in eSQL
SET OutputRoot.JSON.Student.id = InputRoot.XMLNSC.Payload.id

? will this worK?


Try it and see. Much faster than asking here and waiting. If it doesn't work, take a user trace to see why (this is good general advice as well as specific to your question).

xtremeinfo wrote:
how to set JSON as input to HTTP request?


The same way you'd set anything else as input to the HTTP request.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
xtremeinfo
PostPosted: Mon Dec 07, 2015 8:37 am    Post subject: Reply with quote

Newbie

Joined: 03 Dec 2015
Posts: 9

Vitor wrote:
xtremeinfo wrote:
Can i access in Broker like this in eSQL
SET OutputRoot.JSON.Student.id = InputRoot.XMLNSC.Payload.id

? will this worK?


Try it and see. Much faster than asking here and waiting. If it doesn't work, take a user trace to see why (this is good general advice as well as specific to your question).


Actually I was asked to prepare design document as things are not going as planned(message broker not working) , so thats i was asking

Vitor wrote:

xtremeinfo wrote:
how to set JSON as input to HTTP request?


The same way you'd set anything else as input to the HTTP request.


Hmm Unfortunately I do not know how to set anything as input either
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Dec 07, 2015 9:04 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

xtremeinfo wrote:
Actually I was asked to prepare design document as things are not going as planned(message broker not working) , so thats i was asking


In my day (which I accept was a long time ago) design documents didn't contain code, they contained designs.

xtremeinfo wrote:
Unfortunately I do not know how to set anything as input either


Well this explains:

xtremeinfo wrote:
things are not going as planned(message broker not working)


I put it to you that the message broker product is probably working just fine. The lack of knowledge on how to present input to a node, and indeed how to reference items in a message tree, display a fairly fundamental lack of understanding of basic concepts.

You don't need a design document. You need training and/or onsite mentoring. This is the simple stuff - it gets much more complicated very quickly and you'd going to struggle. Push back on whoever's complaining that things are not going as planned and identify the lack of proper developer support as a key reason why.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Exception while trying to hit Restful service (Http Node)
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.