soap
soap copied to clipboard
Parsing error messages
Hi, I use the library to consume SOAP service and when error 500 occurres, the XML returns as string, like following:
{:error,
{:client,
{:parsing_message, 500,
[{'connection', 'close'}, {'date', 'Mon, 21 Aug 2017 09:13:58 GMT'},
{'server', 'serverName'}, {'content-length', '525'},
{'content-type', 'text/xml;charset=utf-8'}], :error, :function_clause}},
"<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body><S:Fault xmlns:ns4=\"http://www.w3.org/2003/05/soap-envelope\"><faultcode>S:Server</faultcode><faultstring>FailtString</faultstring><detail><ns2:RecordName xmlns:ns2=\"http://soap.url\"><errorCode>NOT_FOUND</errorCode><message>Error Message</message></ns2:RecordName></detail></S:Fault></S:Body></S:Envelope>"}
There is generated record for fault message, but it is not used.
-record('P:RecordName ', {
errorCode :: string() | undefined,
message :: string() | undefined}).
How to make it parse XML into a erlang records when SOAP service returns an error?
After further debugging it turned out current version can't process complex detail tags. Only strings. I think they even hard-coded.
-record(faultdetail, {uri :: string(),
tag :: string(),
text :: string()}).
https://github.com/bet365/soap/blob/9e1ae526bd0078ea1d1509e20ae49f46f2efb841/src/soap_fault.hrl#L27
Addressed here: https://github.com/deadtrickster/soap/commit/1b85a239457e0944a75a4423105a21ed151edb04
What's missing:
- operations generated have set faults to empty list/undefined;
- faults (and perhaps responses in generatal) aren't validated that they actually the responses/faults for this particular operation;
- no 1.2 support.