IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this forum will no longer be available. More details available on our FAQ.
Topic
  • 9 replies
  • Latest Post - ‏2019-04-10T10:17:20Z by PUBY_Phil123
Damery
Damery
71 Posts

Pinned topic XQUERY HTTP SOAP ERROR HANDLING

‏2015-02-03T14:19:26Z | http soap sql systools xml

Hello,

I am just dipping my foot in the pool of Systools HTTP functions. Is there a suggested standard way for handling errors with a SOAP service?

I am using HTTPPOSTCLOB to use a SOAP service, but when there is an error I only get SQLSTT=38000. When I am using SOAPUI I see it is able to handle the reply error and display. Not just that the service is down but potentially that my parms are invalid.

When I try with the HTTPPOSTCLOBVERBOSE the table result I get back on an error just tells me error code 500 and "Internal Server Error"

with SOAPUI I get a huge FAULT message in the soap body with error information.

Any help?

  • NickLawrence
    NickLawrence
    69 Posts
    ACCEPTED ANSWER

    Re: XQUERY HTTP SOAP ERROR HANDLING

    ‏2015-05-18T23:04:47Z  

    Hello Nick,

    thanks for your answer.

    I do know this very nice whitepaper. Thanks to it, I could understand and already use these functions with success.

    My question is just regarding the case when the Webservice retrieve an exception: a 500 error code back and a SOAP Fault response. I would like to have the information that states in that Response, because it contains important error messages.

    In this case, with HTTPPOSTBLOBVERBOSE, I receive the HTTP header (with error code 500) but the Response is then null.

    Is that always so (because it is a server error)? Or is there maybe a new version from this UDTF? Is there anything I can do in order to become the response, despite the server error (as it happens in SOAP UI and other tools)?

     

     

     

    Today the verbose functions only support returning what Java refers to as the connection's input stream, and return a NULL value if the request was not successful.

     

    As I understand it, you would like to have access to what Java refers to as the error stream, which includes additional information about the error (instead of the expected response data).

     

    The support today prevents code from attempting to use an error response as valid data - which is good. However what you are asking for would seem to be a reasonable improvement in cases where the server is not using HTTP headers to communicate error information.

     

    We'll consider adding this capability at some point in the future.

     

    Thanks,

  • NickLawrence
    NickLawrence
    69 Posts

    Re: XQUERY HTTP SOAP ERROR HANDLING

    ‏2015-02-05T19:04:34Z  

    The server controls what HTTP response code and message are returned.

    In general 500 "Internal server error" is usually a un-handled exception or bug on the server side....It is not a error the server was expecting or gracefully handled.

    Often times these errors occur because the data being sent to the server is corrupted in some way. You might want to double check that the encoding of the data being sent matches the encoding the server is expecting.

    The HTTPPOSTCLOB function accepts inputs that are CLOB CCSID 1208 (UTF-8), and will cast character data to UTF-8 if necessary. If you are sending XML with an encoding declaration, sometimes that can trip you up.

  • Rita Silva
    Rita Silva
    2 Posts

    Re: XQUERY HTTP SOAP ERROR HANDLING

    ‏2015-05-15T12:38:34Z  

    The server controls what HTTP response code and message are returned.

    In general 500 "Internal server error" is usually a un-handled exception or bug on the server side....It is not a error the server was expecting or gracefully handled.

    Often times these errors occur because the data being sent to the server is corrupted in some way. You might want to double check that the encoding of the data being sent matches the encoding the server is expecting.

    The HTTPPOSTCLOB function accepts inputs that are CLOB CCSID 1208 (UTF-8), and will cast character data to UTF-8 if necessary. If you are sending XML with an encoding declaration, sometimes that can trip you up.

    Hello Nick,

    I am using the HTTP functions in SYSTOOLS and I had the same Problem as described above. In the Webservice I am trying to call from SQL, the entire Exception handling is made throught a Fault Element. So, it is very important to receive the Response, also when the received Error Code is 500. As it happens in SoapUI for example.

    Is there any way to receive the Information in SQL, in this case?

     

    Thank you very much in advance.

  • NickLawrence
    NickLawrence
    69 Posts

    Re: XQUERY HTTP SOAP ERROR HANDLING

    ‏2015-05-18T16:09:48Z  

    Hello Nick,

    I am using the HTTP functions in SYSTOOLS and I had the same Problem as described above. In the Webservice I am trying to call from SQL, the entire Exception handling is made throught a Fault Element. So, it is very important to receive the Response, also when the received Error Code is 500. As it happens in SoapUI for example.

    Is there any way to receive the Information in SQL, in this case?

     

    Thank you very much in advance.

    Yes,

     

    There are 'verbose' versions of the HTTP functions that are table functions. These return both the response and the HTTP headers from the server.

    The HTTP headers are in an XML format and you can retrieve specific information using the XMLTABLE function.

     

    You can read about how to do this in the whitepaper.

    https://www-304.ibm.com/partnerworld/wps/servlet/ContentHandler/stg_ast_sys_wp_access_web_service_db2_i_udf

     

  • Rita Silva
    Rita Silva
    2 Posts

    Re: XQUERY HTTP SOAP ERROR HANDLING

    ‏2015-05-18T20:07:06Z  

    Yes,

     

    There are 'verbose' versions of the HTTP functions that are table functions. These return both the response and the HTTP headers from the server.

    The HTTP headers are in an XML format and you can retrieve specific information using the XMLTABLE function.

     

    You can read about how to do this in the whitepaper.

    https://www-304.ibm.com/partnerworld/wps/servlet/ContentHandler/stg_ast_sys_wp_access_web_service_db2_i_udf

     

    Hello Nick,

    thanks for your answer.

    I do know this very nice whitepaper. Thanks to it, I could understand and already use these functions with success.

    My question is just regarding the case when the Webservice retrieve an exception: a 500 error code back and a SOAP Fault response. I would like to have the information that states in that Response, because it contains important error messages.

    In this case, with HTTPPOSTBLOBVERBOSE, I receive the HTTP header (with error code 500) but the Response is then null.

    Is that always so (because it is a server error)? Or is there maybe a new version from this UDTF? Is there anything I can do in order to become the response, despite the server error (as it happens in SOAP UI and other tools)?

     

     

     

  • NickLawrence
    NickLawrence
    69 Posts

    Re: XQUERY HTTP SOAP ERROR HANDLING

    ‏2015-05-18T23:04:47Z  

    Hello Nick,

    thanks for your answer.

    I do know this very nice whitepaper. Thanks to it, I could understand and already use these functions with success.

    My question is just regarding the case when the Webservice retrieve an exception: a 500 error code back and a SOAP Fault response. I would like to have the information that states in that Response, because it contains important error messages.

    In this case, with HTTPPOSTBLOBVERBOSE, I receive the HTTP header (with error code 500) but the Response is then null.

    Is that always so (because it is a server error)? Or is there maybe a new version from this UDTF? Is there anything I can do in order to become the response, despite the server error (as it happens in SOAP UI and other tools)?

     

     

     

    Today the verbose functions only support returning what Java refers to as the connection's input stream, and return a NULL value if the request was not successful.

     

    As I understand it, you would like to have access to what Java refers to as the error stream, which includes additional information about the error (instead of the expected response data).

     

    The support today prevents code from attempting to use an error response as valid data - which is good. However what you are asking for would seem to be a reasonable improvement in cases where the server is not using HTTP headers to communicate error information.

     

    We'll consider adding this capability at some point in the future.

     

    Thanks,

  • RolandM
    RolandM
    2 Posts

    Re: XQUERY HTTP SOAP ERROR HANDLING

    ‏2016-09-27T11:33:28Z  

    Today the verbose functions only support returning what Java refers to as the connection's input stream, and return a NULL value if the request was not successful.

     

    As I understand it, you would like to have access to what Java refers to as the error stream, which includes additional information about the error (instead of the expected response data).

     

    The support today prevents code from attempting to use an error response as valid data - which is good. However what you are asking for would seem to be a reasonable improvement in cases where the server is not using HTTP headers to communicate error information.

     

    We'll consider adding this capability at some point in the future.

     

    Thanks,

    Hello Nick,

    "The support today prevents code from attempting to use an error response as valid data - which is good. "

    I cannot agree with this statement.

    The Fault Message ist always build differently as the expected answer .

    When getting the HTTP Response Code correctly the developer can implement both ways to parse the expected result and the fault message.

    This would be a behavior every developer would expects to deal with. 

    Currently if there is an error - to find out what was going wrong, is not easy and the developer has no chance to deliver an adequate error message to the user.

    Developers will have to use third-party tools like Soap-UI to enable themselves to find out whats happening and this makes the usage of those functions laborious. 

    From my point of view those functions have to be improved - almost all SOAP clients can do this  - it is just a standard right?

    Best Regards 

    Roland

     

     

  • NR89_Michael_Williams
    1 Post

    Re: XQUERY HTTP SOAP ERROR HANDLING

    ‏2018-05-10T01:30:46Z  

    I was wondering if there was ever a fix for this issue?  I'm using the HTTPPOSTCLOB but the service that I'm calling is returning a http status code of 400 for bad request.  In my case, the request is formatted correctly but the data I'm passing is not.  The response from the service call holds the error message that indicates the reason for the error.  I would like to get that message. 

     

    Thanks,

    Michael

  • RolandM
    RolandM
    2 Posts

    Re: XQUERY HTTP SOAP ERROR HANDLING

    ‏2018-09-28T08:16:35Z  

    Today the verbose functions only support returning what Java refers to as the connection's input stream, and return a NULL value if the request was not successful.

     

    As I understand it, you would like to have access to what Java refers to as the error stream, which includes additional information about the error (instead of the expected response data).

     

    The support today prevents code from attempting to use an error response as valid data - which is good. However what you are asking for would seem to be a reasonable improvement in cases where the server is not using HTTP headers to communicate error information.

     

    We'll consider adding this capability at some point in the future.

     

    Thanks,

    Hi Nick,

    as there was no change to this issue since almost 3,5 years I would like to ask if IBM intends get up-to-date again and keep up with the latest development standards.

    https://blog.restcase.com/rest-api-error-codes-101/

    According to this blogpost, I explicitely want write some extracts here:

     

    A great amount of applications are using Restful APIs that are based on the HTTP protocol for connecting their clients. In all the calls, the server and the endpoint at the client both return a call status to the client which can be in the form of:

    The success of API call.
    Failure of API call.
    In both the cases, it is necessary to let the client know so that they can proceed to the next step. In the case of a successful API call they can proceed to the next call or whatever their intent was in the first place but in the case of latter they will be forced to modify their call so that the failed call can be recovered.

    To enable the best user experience for your customer, it is necessary on the part of the developers to make excellent error messages that can help their client to know what they want to do with the information they get. An excellent error message is precise and lets the user know about the nature of the error so that they can figure their way out of it.

    A good error message also allows the developers to get their way out of the failed call.

    Next step is to know what error messages to integrate into your framework so that the clients on the end point and the developers at the server are constantly made aware of the situation which they are in. in order to do so, the rule of thumb is to keep the error messages to a minimum and only incorporate those error messages which are helpful.

    HTTP defines over 40 standard status codes that can be used to convey the results of a client's request. The status codes are divided into the five categories presented here:

    1xx: Informational - Communicates transfer protocol-level information
    2xx: Success -Indicates that the client's request was accepted successfully.
    3xx: Redirection - Indicates that the client must take some additional action in order to complete their request.
    4xx: Client Error - This category of error status codes points the finger at clients.
    5xx: Server Error - The server takes responsibility for these error status codes.
    HTTP & REST

    If you would ask me 5 years ago about HTTP Status codes I would guess that the talk is about web sites, status 404 meaning that some page was not found and etc. But today when someone asks me about HTTP Status codes, it is 99.9% refers to REST API web services development....

     

    Best Regards

    Roland

     

    Updated on 2018-09-28T08:19:47Z at 2018-09-28T08:19:47Z by RolandM
  • PUBY_Phil123
    PUBY_Phil123
    1 Post

    Re: XQUERY HTTP SOAP ERROR HANDLING

    ‏2019-04-10T10:17:20Z  

    Today the verbose functions only support returning what Java refers to as the connection's input stream, and return a NULL value if the request was not successful.

     

    As I understand it, you would like to have access to what Java refers to as the error stream, which includes additional information about the error (instead of the expected response data).

     

    The support today prevents code from attempting to use an error response as valid data - which is good. However what you are asking for would seem to be a reasonable improvement in cases where the server is not using HTTP headers to communicate error information.

     

    We'll consider adding this capability at some point in the future.

     

    Thanks,

    Hi Nick,

     

    we are also requesting the handling of errors in HTTP UDFs and this development would be very useful. This seems available on z / OS http://www-01.ibm.com/support/docview.wss?uid=swg1PI12714, what about for DB2 for I?

     

    Best regards.

     

    Philippe