Sometimes I send an invalid SOAP request to a web service and receive a HTTP 500 Internal Server Error with an according SOAP Fault element in the SOAP body. Say, it's because I have sent a request with data in a newer XSD version which the older web service does not understand, and the SOAP Fault's faultstring does tell via a validation message which element is unexpected, thereby helping to solve the problem.

Is it possible to receive that SOAP Fault element within a web client procedure?

Currently, I'm using a web client procedure of type 'HTTP:POST:text/xml' so I can usually receive the full response including its headers.

However, when the web service returns a HTTP 500 status, the web client procedure raises a -983 SQLCODE ("HTTP request failed. Status code '500 Internal Server Error'"), and so I cannot access the SOAP response with the SOAP Fault details. Only the web client log (dbsrv12 -zoc) contains the full SOAP response.

I would prefer to be able to return the SOAP Fault message to the client. Is there a way to do so?

asked 31 Mar '16, 05:18

Volker%20Barth's gravatar image

Volker Barth
30.0k294448654
accept rate: 32%

Does the ERRORMSG() contain anything of use, inside an EXCEPTION WHEN OTHERS THEN block?

Or the TRY CATCH ERROR_MESSAGE() call?

(31 Mar '16, 07:56) Breck Carter
Replies hidden

Well, I'm on v12.0.1 here, so TRY/CATCH/ERROR_MESSAGE() are not available.

However, I'm using the ERRORMSG() function within an exception handler, and it just returns the cited error message "HTTP request failed. Status code '500 Internal Server Error'".

According to the docs, that error message for SQLCODE -983 has just one parameter ("HTTP request failed. Status code '%1'), so I guess there's no chance to give more details within the error message itself.

(31 Mar '16, 09:05) Volker Barth

With version 17.0.4 - cf. the news - it's now possible to receive a SOAP Fault element when setting the new HTTP option EXCEPTIONS=OFF.

Note that quote from the docs:

When set to OFF, HTTP client functions will always return a response, independent of the HTTP status code. The HTTP status code will not be available.

So the caller is now responsible to check whether the desired result or an exception has been returned by the web client function/procedure.

Thanks for the nice enhancement!

permanent link

answered 02 Aug '16, 11:50

Volker%20Barth's gravatar image

Volker Barth
30.0k294448654
accept rate: 32%

edited 02 Aug '16, 11:50

Thanks for the nice enhancement!

Particularly as during my tests with v17, I noticed that the syntax for "SET <protocol-option-string>" is checked more strictly (v12.0.1 apparently accepts several such SET clauses, v17.0.4 does not), and my initial "corrections" led to faulty requests, so I surely got those SOAP faults unexpectedly...

(02 Aug '16, 12:38) Volker Barth
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×61
×21
×16

question asked: 31 Mar '16, 05:18

question was seen: 330 times

last updated: 02 Aug '16, 12:39