PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 2024 → Catching errors in  SOAPRunXML/SOAPGetResult
Catching errors in SOAPRunXML/SOAPGetResult
Started by Malc, Feb., 14 2019 4:53 PM - No answer
Posted on February, 14 2019 - 4:53 PM
Hi Guys

Many years ago I wrote some routines to access a UK HMRC WebService. All was good.
Recently, I had some issues with the service calls failing, but I was not receiving suitably descriptive errors

The test url is: https://tpvs2.hmrc.gov.uk/ws/ncts/service

The bad message I am using to test is:

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ncts="http://webservices.hmrc.gov.uk/ncts" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:hmrc="http://www.hmrc.gov.uk/ws/info-header/1"><soapenv:Header><wsse:Security><wsse:UsernameToken><wsse:Username>UnknownUser</wsse:Username><wsse:Password>BadPassword</wsse:Password></wsse:UsernameToken></wsse:Security><hmrc:Header><hmrc:VendorDetails><hmrc:Vendorname>Impatex Computer Systems Limited</hmrc:Vendorname><hmrc:VendorURI>http://www.impatex.com


The responses to this message are:


SOAPRunXML returns true

ErrorOccurred still false

SOAPGetResult(SOAPXMLResult) returns "<" (yeah - a single angle bracket!)

SOAPGetResult(SOAPResult) fires an exception "A value should have been returned by 'SOAPGetResult'."

SOAPGetResult(SOAPHTTPResult) returns

HTTP/1.1 500 Internal Server Error
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Type: text/xml; charset=UTF-8
Content-Length: 312
Date: Thu, 14 Feb 2019 15:45:13 GMT
Connection: close
Set-Cookie: JSESSIONID=clNHZS4tnz8WKMKGjf6lvj0HKCrKkRPjlL0htgLhMyJvJFDFvQnQ!1092665171; path=/<CR>Set-Cookie: TSb6efe0=a20ec05f6192c66d8f3ab5ebea1d5557ac0ab90f1f1abb115c658d0860ac0ec5d4b1d6de; Path=/<CR><><31>‹<8><0><0><0><0><0><0><3>Œ‘1OÃ0<16>…ÿŠå¥Sì<EOT><24>P”¤<2>‰N0A%V+>Z‹ô\圤ý÷œãPÊ<EOT>C¤gß½ïîÅÕútèÄ<8>=9µ,T.<5>`ë­Ã]-·o›ì^<10><10><6>­é<B-Ï@rÝT€cù„#tþ<8>‚<17>H%_Õr<31>±ԚÚ=<28><12>)®7GåûŽBÃâÑrqÈ]\Ó4©évn¾ÉóB¿¿<¿Î<SPC>ÌaÜ¡…oWdñšÿ™—²\ͳÏ“)ࣷç¤6fèÂBøˆú°¾%å<>9Ê8<22>ΰ‰(<2>ï43S)žò"ãBü<SPC><29>z<23>Î<25><11>8…ŒºâµxèŒæ…¡™<21>u<29>؇!ì<1>ƒkMàGªôOW2Pè9aó»M$o)¶<EOT>½Xmñ<19>ý„ñ°<18><22>ЁU<11>i±Wú<18>tÑ)¾¾~êæ<11><0><0>ÿÿ<3><0>®Kþ¡0<2><0><0>



At least the HTTPResult returns me a 500 Internal Server Error.

BUT

If I do the same message via Postman.exe (testing tool, free version available), I get

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<env:Body>
<env:Fault xmlns:fault="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<faultcode>fault:FailedAuthentication</faultcode>
<faultstring>Authentication Failed: User 'UnknownUser' denied.</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>

Which is much more useful - particularly as in this instance the user id that was being used had been 'accidentally' deprecated :).

Does anyone have any ideas how I can improve my error handling?

Cheers

Malc