[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Calling a SOAP Web service w/HTTPAPI



Tom,

I hope you haven't given up...web services running on the IBM i are pretty cool!

It would appear your knowledge base is relatively low and you are looking for the quick way through. Unfortunately, unless your web service fits one of the examples exactly, you will have to learn about xml and HTTPAPI.

Fortunately, this is pretty easy. Scott's article will get you up to speed fairly quickly.

In addition, there are a ton of resources that talk about xml on the web. In 10 minutes you can breeze through http://www.w3schools.com/xml/default.asp and get a grasp on xml.

You are using a web service from a provider. They most likely have a "public" definition of the service available inside a WSDL document. This is the document SOAPUI is looking for. The learning curve on SOAPUI is less than 20 minutes to find the "well formed xml" (you don't need all the functions in SOAPUI).

One thing I've wondered about and maybe you can help answer this question...how come people ask for help about how to write a particular program but don't produce the necessary documentation to allow that to be written? Or maybe you were asking for instructions on how to use EXAMPLE18 and not particular code?

The "what is this code doing" part of HTTPAPI takes some getting used to. It isn't hard to understand once you figure it out, but getting there can be challenging.

EXAMPLE18 is the currency converter example? The soap message obviously needs changes. The "xmlns:tns" is specific to the web service. All the elements with "tns" are specific to the service. This is where SOAPUI really helps. It will build the XML for you with correct elements.

The http_url_post_xml will post the SOAP to the URL listed. So, change the first parameter to point to your web service. Leave the next two parameters (SOAP and SOAP length). The next parameter is passed as a *NULL. You can probably do the same. The next parameter refers to the Incoming procedure that is in EXAMPLE18. Once HTTPAPI receives the XML, it will read through the XML and "call Incoming" for each element it encounters (specifically it will call it when it sees the /element). When Incoming sees the element called "ConversionRateResult", it converts what it finds in "value" to rate using the C (Unix) function atof. The parameters to Incoming are set and mostly do not need to be changed. For the most part, you can just add additional checks to incoming to pull out the values you need. There is a technique to this however. Notice "rate" is declared in the main program and its address is passed to the procedure. Also note that rate is declared on the PI as 8F (Scott's GEOIP example shows a string being passed). From the various examples of parsing the XML, you will see that variously passed as strings and numbers. You will have to decide what fits your service or if you have to retrieve multiple values. If you have to return multiple, you will build a data structure and pass that instead of a discrete value.

Just so you know...Thomas Raddatz has an utility to take a WSDL and generate a stub module or program for you. Again, a little learning curve but assuming you have access to WSDL, you can generate a complete module/program in short order. It can be downloaded here: http://www.tools400.de/English/Freeware/WSDL2RPG/wsdl2rpg.html Look in the FAQ folder for quick start instructions under "How to create a Test Program".

Good luck. Ask questions...most are answered by Scott or someone else on the list.
Mike 
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------