Author |
Message
|
sebastia |
Posted: Thu Mar 20, 2014 12:56 am Post subject: SOAP Req, Generic WebService - namespace ? |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
Hi.
The SOAP Request node has a "operation mode" checkbox. You can either
*) invoke a specific web service defined by a WSDL interface
*) invoke a generic web service
We want to use the second option, also called "gateway mode".
The description says
"Gateway mode allows you to configure your flow to handle generic SOAP request/response and one-way messages, or to act as a facade between multiple web services clients and multiple back-end web services providers. The node can onvoke any binding operation."
Perfect - that is EXACTLY what we need.
Now, how to set destination URL ? No problem :
Code: |
SET OutputLocalEnvironment.Destination.SOAP.Request.Transport.HTTP.WebServiceURL = newUrl ; |
Next - how to set "Operation" ? No problem :
Code: |
SET OutputLocalEnvironment.Destination.SOAP.Request.Operation = 'myOperation' ; |
Last : what about NAMESPACE ?
My first webservice requires
Code: |
declare q0 NAMESPACE 'http://wsServer.myfirst.com/' ; |
And the second web service requires
Code: |
declare q1 NAMESPACE 'http://tod.ws.com/' ; |
How can I change namespaces between different web services ?
Sebastian. |
|
Back to top |
|
 |
fatherjack |
Posted: Thu Mar 20, 2014 3:50 am Post subject: Re: SOAP Req, Generic WebService - namespace ? |
|
|
 Knight
Joined: 14 Apr 2010 Posts: 522 Location: Craggy Island
|
sebastia wrote: |
Last : what about NAMESPACE ?
My first webservice requires
Code: |
declare q0 NAMESPACE 'http://wsServer.myfirst.com/' ; |
And the second web service requires
Code: |
declare q1 NAMESPACE 'http://tod.ws.com/' ; |
How can I change namespaces between different web services ?
Sebastian. |
As you have described above? Or am I misunderstanding? What problem are you seeing when you use the node in gateway mode? _________________ Never let the facts get in the way of a good theory. |
|
Back to top |
|
 |
sebastia |
Posted: Thu Mar 20, 2014 3:57 am Post subject: |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
Jajaja - thanks Jack, now I see I did a very bad description.
Let me improve it.
I want to have a TABLE with all the possible web services.
So, I receive a message and by its contents, calculate the index to the table, where someone has stored
*) the destination URL
*) the remote OPERATION.
But looks like I need to setup a "namespace" before going into SOAP Request node.
How can I get the namespace from a table AND SET IT ?
The sentence "declare" is not a run time sentence, but coding time.
I need to change namespace on run time ...
Tx. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Mar 20, 2014 4:07 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Why do you need the namespace?
What part of the message will it be attached to?
How are you otherwise building the message that is being provided to the SOAPRequest node? |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Mar 20, 2014 5:31 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Can you specify if the need for a namespace is attached to the passing of the operation in the LocalEnvironment?
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
fatherjack |
Posted: Thu Mar 20, 2014 7:22 am Post subject: |
|
|
 Knight
Joined: 14 Apr 2010 Posts: 522 Location: Craggy Island
|
sebastia wrote: |
How can I get the namespace from a table |
The same way you are getting your URL and Operation from a table.
sebastia wrote: |
AND SET IT ? |
DECLARE ns NAMESPACE etc. and then put it in the message you are building. _________________ Never let the facts get in the way of a good theory. |
|
Back to top |
|
 |
sebastia |
Posted: Fri Mar 21, 2014 12:40 am Post subject: |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
The actual code, that runs perfectly, is this one:
Code: |
declare ws_num char ;
set ws_num = trim ( InputRoot.XMLNSC.Mensaje.wsn ) ;
CASE ws_num
WHEN '1' THEN -- <Mensaje> <Evento> EVENT/WS </Evento> <wsn> 1 </wsn> </Mensaje>
declare q0 NAMESPACE 'http://wsServer.myfirst.com/' ;
SET OutputLocalEnvironment.Destination.SOAP.Request.Transport.HTTP.WebServiceURL = 'http://localhost:8080/wsServer_hello' ;
SET OutputLocalEnvironment.Destination.SOAP.Request.Operation = 'getGreeting' ;
set OutputRoot.SOAP.Body.q0:getGreeting.arg0 = 'sebasV2.a' ;
WHEN '2' THEN -- <Mensaje> <Evento> EVENT/WS </Evento> <wsn> 2 </wsn> </Mensaje>
declare q1 NAMESPACE 'http://tod.ws.com/' ;
SET OutputLocalEnvironment.Destination.SOAP.Request.Transport.HTTP.WebServiceURL = 'http://localhost:1212/TOD_server' ;
SET OutputLocalEnvironment.Destination.SOAP.Request.Operation = 'say_TOD' ;
set OutputRoot.SOAP.Body.q1:say_TOD.arg0 = 'sebasV2.b' ;
else
SET OutputLocalEnvironment.Destination.SOAP.Request.Transport.HTTP.WebServiceURL = 'http://localhost:8080/not.found.com' ;
SET OutputLocalEnvironment.Destination.SOAP.Request.Operation = 'unknown' ;
END CASE ;
|
As you can see, the text of the message is not important (by now).
We need to generalize this "CASE" approach in order to be able to get the URL and Operation values from a table, indexed by "ws_num".
And the "declare" statement is the problem.
Jeff - I cant answer "why I need the namespace".
What I see is that it is used in the setting of the Output :
Code: |
set OutputRoot.SOAP.Body.q0:getGreeting.arg0 = 'sebasV2.a'
set OutputRoot.SOAP.Body.q1:say_TOD.arg0 = 'sebasV2.b' ; |
... because I know the XML that has to be generated has the form
Code: |
<q0:getGreeting><arg0>sebasas</arg0></q0:getGreeting>
|
or
Code: |
<q0:say_TOD><arg0>pepeta</arg0></q0:say_TOD> |
for the second case.
So, I think I can answer to
Quote: |
the need for a namespace is attached to the passing of the operation in the LocalEnvironment? |
... with a "yes", right ?
Thanks.
mr FatherJack : we need our code to have this structure :
Code: |
set ws_num = trim ( InputRoot.XMLNSC.Mensaje.wsn ) ; -- get index
SET OutputLocalEnvironment.Destination.SOAP.Request.Transport.HTTP.WebServiceURL = Table_URLs [ ws_num ] ;
SET OutputLocalEnvironment.Destination.SOAP.Request.Operation = Table_Operations [ ws_num ] ; |
... and now comes the namespace I dont know how to manage ... |
|
Back to top |
|
 |
Armageddon123 |
Posted: Fri Mar 21, 2014 4:27 am Post subject: |
|
|
Acolyte
Joined: 11 Feb 2014 Posts: 61
|
|
Back to top |
|
 |
sebastia |
Posted: Fri Mar 21, 2014 5:07 am Post subject: |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
Looks pretty good to me ... Shall try Monday first hour.
Today .. it's Friday 3 pm here ...
Have a nice weekend all ! |
|
Back to top |
|
 |
sebastia |
Posted: Tue Apr 01, 2014 5:07 am Post subject: |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
Hi, coleagues - here you are the code to call a web service in both modes :
1) specific, using WSDL
2) generic (SOAP Request node in gateway mode)
Requires 3 parameters:
1) namespace
2) URL
3) operation
Code: |
CASE ws_num
WHEN '1' THEN -- <Mensaje> <Evento> EVENT/WS </Evento> <wsn> 1 </wsn> </Mensaje>
declare q0 NAMESPACE 'http://wsServer.myfirst.com/' ;
SET OutputRoot.SOAP.Context.Namespace.(SOAP.NamespaceDecl)xmlns:q0 = 'http://wsServer.myfirst.com/' ;
SET OutputLocalEnvironment.Destination.SOAP.Request.Transport.HTTP.WebServiceURL = 'http://localhost:8080/wsServer_hello' ;
SET OutputLocalEnvironment.Destination.SOAP.Request.Operation = 'getGreeting' ;
set OutputRoot.SOAP.Body.q0:getGreeting.arg0 = 'sebas using 1st web service' ;
WHEN '2' THEN -- <Mensaje> <Evento> EVENT/WS </Evento> <wsn> 2 </wsn> </Mensaje>
declare q1 CHARACTER ;
set q1 = 'http://tod.ws.com/' ; -- (1) input
declare operacion CHARACTER ;
set operacion = 'say_TOD' ; -- (2) input
SET OutputRoot.SOAP.Context.Namespace.(SOAP.NamespaceDecl)xmlns:q1 = q1 ;
SET OutputLocalEnvironment.Destination.SOAP.Request.Transport.HTTP.WebServiceURL = 'http://localhost:8181/TOD_server' ; -- (3) input
SET OutputLocalEnvironment.Destination.SOAP.Request.Operation = operacion ;
CREATE LASTCHILD OF OutputRoot.SOAP.Body NAMESPACE q1 NAME operacion ; -- this line does the trick
set OutputRoot.SOAP.Body.*.arg0 = 'sebas uses 2nd web service' ; -- web service input parameter
else |
Enjoy. Sebastian. |
|
Back to top |
|
 |
|