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

RE: Webservice SOAP



Sounds like you need a little explanation and some hand holding. Sometimes I like being condescending, but generally I expect people to have read a few articles and tried a few examples and tutorials (and maybe read through the forum archive) so I don't have to sound that way. So, at the risk of being condescending today, I offer these words of enlightenment.  

A web service is a conversation between a server and client. There is much more to it than that but the IBMi can handle it just fine. You need to learn about the pieces of the web service. I know lots of people just want to "click on this button and enter the number 4 on this screen and then it prints on my printer", but you really should know a bit about what a web service is, how it works, what is involved, and various options.

A web service usually has a WSDL file available. This WSDL describes the options, parameters, layout, required and optional elements of both the message it receives and the message it sends back. You usually get a copy of the WSDL by downloading from the server hosting the web service. When you get it, you usually use a tool to decipher it. SOAPui is free tool (as well as paid tool) that you can use to decipher the WSDL. It is invaluable in figuring out complex web services.

Web services usually run on web servers over standard HTTP protocol.

HTTPAPI is a HTTP protocol tool. It allows you to make HTTP requests. There are GET and POST requests and it is important to use the one the web service is expecting. HTTPAPI knows how to receive a response from the web server. That is really all that HTTPAPI does. Now it does provide various procedures to do these things in different ways. It is up to the programmer to decide how they want to do those things.

How do you learn what HTTPAPI can do and how you do it? Look in the source file QRPGLESRC. In there, you will find EXAMPLE programs. Start with EXAMPLE1 and read through the program and try them out. I'd suggest you start with the EXAMPLE programs from the latest beta and then look over the EXAMPLE programs from the released version (you will need to save them somewhere as you should be using the Beta code to code your project). The EXAMPLE programs show various ways of interacting with HTTPAPI and the EXPAT program.

EXPAT? That is an open source tool, Scott ported to the IBMi and can be integrated into HTTPAPI to provide XML parsing capability. Since the EXAMPLE programs really need EXPAT, you should consider that your first line of parsing XML. You can parse XML other ways. RPGLE includes support for parsing XML and it is getting better with every release.

In RPGland, there is no built-in support for creating XML. But there are projects that various people use to do that. Sometimes they are actual attempts at creating XML and other times it is a helper app. But many people, simply create the XML 'by hand' inside of the RPG program. If you know what the XML is suppose to look like and fairly simple to implement, feel free to implement in RPG.

Close by HTTPAPI is a project called WDSL2RPG by Thomas Raddatz. Using the WSDL, it generates a service program for creating and parsing the XML of your web service. If your WSDL is complex, use this tool to help you get there. You will need to learn that tool as well.

Just to confuse you a bit, Scott just wrote an article about another tool called WSDL2RPG that describes how to consume web services using IWS. Find that here http://systeminetwork.com/article/consume-web-services-ibms-iws

So, you can get "there" in lots of different ways. Do the EXAMPLE programs and you will get a feel for how HTTPAPI and Expat work. In the current BETA, a couple of them will probably be close to what you would use.

When you get comfortable with HTTPAPI, look in QRPGLESRC and check out HTTPAPI_H. This has ALL the HTTPAPI procedures in it that can be invoked. Since your input XML data looks like it could get lengthy, you might want to consider writing it the IFS and then using

http_url_post_stmf_xml(): Post data to CGI script from stream file and receive/parse an XML response

This procedure will POST the stream file directly to your web service and receive back the relatively small return XML which you will then parse to find the success or failure code.

Good luck. This stuff is hard to get your hands around at the start but really not too hard once you start to look at it. Oh, the beta, get it here: http://www.scottklement.com/httpapi/beta/ It is mainly fixes and is a good starting point if you are just getting going on web services.

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------