Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Posting to a webservice

 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. If somebody has a minute, I just wanted to ask a couple of quick questions...

records in a Lotus Notes database have to be posted (and retrieved from, but i'll worry about that later) to an Oracle web service via HTTP. THe web service of course has a posted wsdl schema.

the only way I can think of that i can post the Lotus Notes records to the web service is via HTTPConnection and writing in the hardcoded xml format to a BufferedWriter stream, ie...

...String xmldata = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<env:Envelope " +
"env:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
"xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" " + ...

Is there a way that I can leverage the known wsdl schema to create the SOAP message out of Lotus Notes as opposed to hardcoding string literals into a writer? Thank you very much for reading this.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Axis toolkit can create Java client classes for a particular WSDL (using a tool called wsdl2java). These will allow you to call methods to set the parameters, and post those to the WS. That way you do not have to worry about XML and Writers.

Or do you also have to retrieve those records from the DB and run the whole thing inside of Notes?
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...yeah, eventually i think i have to perform the reverse, post unique parameter(s) to the db web service and as i perceive, parse the response xml and update a lotus notes record.

I was looking at Apache Axis but I was thinking that although Domino supports java, it isn't really a j2ee server or implementation, so I don't think axis and domino will be compatible...?...

in a nutshell, a lotus notes guy is going to write a lotusscript agent that will handle the business side and deliver the fields that need to be posted to the web service in a single notes document (representing a single record in oracle)...

then the thought was that the lotusscript agent would call a lotus notes based java agent (opting for java to take advantage of i/o and streaming capabilities) to create the SOAP xml and post it to the web service.

I do hear that SOAP will be installed on the lotus notes server, but i've yet to determine how that would be of assistance...
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those classes created by wsdl2java would not requires a server to run - it's just the client (although they do require the Axis classes to be present). And the response can be accessed on a SOAP/XML element level (or even a method/object level if this is an RPC-style WS), which is more convenient than handling the XML yourself.
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I was diverted to another project but i am going to revisit this. I am kinda confused with the axis download, i have the axis-bin-1.4.zip and i understand to download this into webapps/axis (the default) but within the zip itself, the files seem to be all flat. Shouldn't there be a folder structure inside the axis download file, including WEB-INF? thank you.
[ July 05, 2006: Message edited by: Tom Griffith ]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somewhere inside your download, there should be a *.war file. Put that into Tomcats webapps directory, and it should do the right thing.
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok ulf, I've worked through everything...installing/configuring apache and I fed it the wsdl from the target web service using wsdl2java and it created stub classes for each wsdl element, complex type etc. Now I'm not totally sure what I need to do with them in lotus notes. Do I dump the stub classes into the lotus notes classpath and just create objects with them and write/stream the object (as opposed to writing out xml elements) via urlconnection to the remote web service?...thanks for your help in getting me started down this path or whatever...
[ July 14, 2006: Message edited by: Tom Griffith ]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to deal with URLs and connections - the generated classes do all that. The client you still need to create instantiates a ServiceLocator, obtains a handle to the Service from it, and uses that to invoke the business methods. It could be as little as 3 lines of code. Check out example6 in the samples/userguide folder of the Axis installation - it shows a sample client for classes obtained through WSDL2java.
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you ulf. this is really, really neat. It is kinda intimidating at first to get this going, but it's a slick utility.
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ulf, if you have a minute, for several reasons, the customer wants the xml tags written up to the web service similar to what I initially posted. They want to maintain the xml SOAP schemes/tags inside lotus notes for four operations and utilize their lotus notes resource to maintain everything and assign values to the tags, etc as needed (the call a java agent to post it to the service). Like I said, there are four operations that occur all specified in the wsdl that axis created stubs and classes for (not that i can use it now) when i fed the wsdl into axis. Since now I am left writing xml via httpurlconnection, I was wondering if the url that I have to create the inputstream for on the POST requests has to indicate the operation, or is it just the blanket url for the web service found in the wsdl, for instance:

<soap:address location="http://localhost:8080/customer/services/MyWebServiceSOAP"/>

Like I said, there are four operation in the wsdl, i.e:

<wsdl o peration name="UpdateCustomer">...

What I gather from feeding the wsdl into axis myself is that the address in the <soap:address location=.../> tag should suffice as the inputstream from the httpurlconnection since there are bindings created amongst all the operations when the web service is deployed. Is that right..if it makes any sense? Thank you again.
[ July 17, 2006: Message edited by: Tom Griffith ]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right, the operation is part of the SOAP body, not part of the URL. The URL only contains the "name"/"ID" of the collection of the four operations deployed together (MyWebServiceSOAP in this case).
 
Tom Griffith
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you ulf. I was going to map the operation in the SOAP request by setting the SOAPAction priperty on the httpurlconnection request. However, two of the operations have no soap action namespace indicated...for example...

<wsdl:binding>
...
<wsdl o peration name="InsertCustomer">
<soap o peration />

<wsdl o peration name="UpdateCustomer">
<soap o peration />

<wsdl o peration name="ProcessCustomer"><soap o peration soapAction="http://myspace.com/MyWebService/ProcessCustomer"/>


</wsdl:binding>

How will the SOAP message find the InsertCustomer and UpdateCustomer operations? Oh, wait, thats indicated in the SOAP ~Body~, right? Soap action is indicated in the header. Does this mean the UpdateCustomer request doesn't get a SoapAction tied to it in the request header? Thank you again for confirming stuff like this.
[ July 18, 2006: Message edited by: Tom Griffith ]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SOAP action is optional. The SOAP engine examines the body of the SOAP message to determine which operation is meant, and then invokes the respective method. That's nothing you need to worry about.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic