Consuming a webservice returns error 500 because of the lack of a Header property
Estimated Reading Time: 1 MinutesThe solution to the error 500 is not always the one that will be discussed below, though it is a good starting point to check and resolve if that is the case.
When you are going to develop a webservice client program that will consume webservices, it is a good practice to test the webservices consumption on a third-party software like SoapUI.
In this article we use SoapUI as an example. Other options are available though. For instance if you have a REST webservice you could use Postman instead.
When you test the webservice in SoapUI you have an option to check the input XML in Raw format as follows:
In this screenshot, you can see an entry for SOAPAction.In order to resolve the error 500 you may need to send this Header property before invoking the doPostEx method, in addition to the normal steps to develop a client webservice (using the stream2wrk to generate the working-storage section structure for the input XML, output XML, etc.). This Header property is written as follows.
http:>setHeaderProperty("soapaction", '"http://www.someurl.com/services/SysLogin"')
Notice that the value of the header includes double quotes [ " ] at the start and end of the string, therefore, the whole value is enclosed in single quotes [ ' ].
With this additional code, the client program will forward the same header property that SoapUI sends before trying to consume the webservice, fixing the error 500. You will get a successful return code 200.