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

RE: ProcessXMLStringToDB



Welcome! This whole web service thing is pretty cool. But you do have to build at least a small base of knowledge.

Just to expand a little bit for Ernie and those who are new...

Did you do (work through) the examples before trying to make something fit?  Are you using the release code or the BETA code?

When you went through the examples, did you notice the http_debug(*on) or callp http_debug(*on) statement? There is a good reason for those - it will show what is being sent and what is being received. It is much easier to tell what is right and wrong when you see the actual transactions. So, the first step with HTTPAPI is to turn on debugging.

The WSDL helps you and the rest of us determine what exactly the web service is asking for. So, it is important to include that or have sufficient knowledge of it to explain that you are sending the right data and what to expect back from the service. From the documentation you sent though, you can access this service several different ways.  The first two are soap methods using XML, the third and fourth are "simple" GET and POST transactions.

The content type you send should match which method you are using. It is sent in the HTTP header and helps the server/service to know what it is receiving from the program. Some servers/services require this to be an exact match or they will not process the request. So, if you look at the documentation you sent along, the content-type strings for the different methods are:

Content-Type: text/xml
Content-Type: application/soap+xml
Content-Type: text/xml
Content-Type: application/x-www-form-urlencoded

The samples you sent also show the returning data that includes a content-type (so your program can know what to expect - but you already know that because of what the service is returning to you). Those are the lines after the HTTP/1.1 200 OK lines. So, if you were doing the post method, you would be sending:
>       ContentType='application/x-www-form-urlencoded';

But it would appear you are trying to do a SOAP method (based on the stmf being .xml) and so an appropriate Content-Type is either of the first two depending on what you are sending.

Okay, so along the way, you are asking yourself, what is the difference? Here is my simple explanation: 
GET: this is just like you typed in the location bar of your browser.
POST: almost like typing the location bar of the browser but you usually format the data in a slightly special way. In HTTPAPI, the usual way to do this would be to use the WEBFORM support to build parameter pairs (name=value). Parameters can be very large using this method.
SOAP 1.1/1.2: Both of these are versions of POST that use XML to send and receive data. Formatting for simple services can be accomplished within a program quite easily (yours appears to be simple). Formatting for complex services is much easier using a tool. Sometimes, the exact coding is not intuitive hence SOAPUI (open source web services/XML "helper" software) and on the IBMi WSDL2RPG.

I like simple myself. Depending on what "string" looks like, I'd opt for either the GET or POST, however the SOAP calls are pretty easy to do as well and in all cases you will still need to parse the returning XML to look for "application error". The RC code that you have in the program simply means that HTTPAPI was able to communicate with the server successfully. You really need to look at the returned XML for "string" and see what it says. This, btw, will be shown in the debug log. So, you will be able to see how the server responded to your request.

So, finally, you are going to ask next...Where do I find the debug log? By default, it is in here:

WRKLNK '/tmp/httpapi_debug.txt'

Post back soon! Hope this was helpful on the journey.

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