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

RE: How to access returned XML doc on HTTP 500 error.



   I had looked to see if an XML document was available after post of my
   XML returned.  Here is my code that deals with the API:

   /free

    http_debug(*on: '/httpapi_debug.txt');

    rc = http_url_post_xml(WebSvcURL

                          : %addr(XMLRequest)

                          : %len(XMLRequest)

                          : *NULL

                          : %paddr(ParseResponse)

                          : *NULL );

    if (rc <> 1);

       BankFaultDsc = http_error();

       // FIXME: REPORT ERROR TO USER

       *inlr = *on;

       return;

    endif;

    *inlr = *on;

   /end-free

           The ParseResponse process was the first place that I checked,
   using STRDBG.  Normally the debug session will step through that.  When
   I create an error by passing a non-ISO date when ISO is expected, then
   the http_error() returns just the web server HTTP 500 error text.  If I
   look at the debug text, there is a small XML document at the end that
   gives better information.  Based on that, the API has access to better
   error info, but how does a user program get to it.

           I believe that this type of error is normally caught during
   development and should not occur in production.  There always the
   chance that the schema for the XML could change and break my code, so I
   want to have code that will provide the best information that I can.

   Hmm interesting question you bring up. In theory, a 500 error means the
   server encountered an unexpected condition. That is like a plumbing
   problem and shouldn't really be a user issue. But I can see that maybe
   you want to empower the user to call the supplier with the problem...

   Did you try using your "Incoming" to parse for the error message? I
   don't think HTTPAPI cares about the error other than to return the
   error back to you. Sometimes, HTTPAPI does cut short the conversation
   when bad things happen but it looks from a brief look at the code that
   your "Incoming" will be called even if you get a 500 response.

   Otherwise, you should be able to process the xml document you get back
   if you save the data. Pseudo code:

   Post(url: etc: myIFSFile)

   if rc <> 1;  // I have an error

    Msg = http_error

    If rc = 500; // read the xml for the error

      http_parse_xml_stmf(myIFSFile: HTTP_XML_CALC:*NULL : FindMyError:
   *NULL);

      // do something with the error data

    endif;

   else; // good post, parse xml for data

    http_parse_xml_stmf(myIFSFile: HTTP_XML_CALC: *NULL : FindMyData:
   *NULL);

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