0

I am using NUSOAP client with a hard coded XML request to communicate with a Server to read a response from a Websphere server. I use nusoap_client->send to send the request.

$result = nusoap_client->send. Then SOAP response is obtained from $result. Perfect. Now I am trying to get a server response from an upgraded server (probably not using Websphere. Not sure). SOAP namespace is also changed and the response has some prefix.

I no longer get the SOAP response from $result (when I run strlen() I get zero size) . But I can call nusoap_client->responseData to get a response below. So I try to parse with simplexml_load_string on PHP5.x but it doesnt seem to parse and error message => syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING. Where could I be going wrong?

$stringer = <<<XML <?xml version='1.0' encoding='ISO-8859-1'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <ser:getCarResourceResponse xmlns:ser="http://sos.joburg.com/webservice/ecare/services"> <ser:GetCarResourceReply> <ser:resCode>10652981251</ser:resCode> <ser:departName>Ingolstadt</ser:departName> <ser:resStatus>4</ser:resStatus> <ser:statusDate>2022-05-09 09:24:50</ser:statusDate> <ser:isScheduled>0</ser:isScheduled> <ser:departStatus>0</ser:departStatus> </ser:GetCarResourceReply> <ser:ResultOfOperationReply> <ser:resultCode>0</ser:resultCode> <ser:resultMessage>Successful</ser:resultMessage> </ser:ResultOfOperationReply> </ser:getCarResourceResponse> </soapenv:Body> </soapenv:Envelope> XML; $log->logInfo(print_r(simplexml_load_string($stringer), 1)); 
5
  • is the second last line XML; in the codeblock included in the response from the server? If so, then this is likely the error and you've to strip it away before parsing. Commented May 22, 2022 at 20:24
  • The syntax error you mention is an error in your PHP syntax, not in the XML. Most likely you made a typo somewhere. Commented May 22, 2022 at 20:32
  • 2
    @David That's part of the PHP, it just wasn't showing properly because the markdown wasn't quite right. Commented May 22, 2022 at 20:34
  • sorry I see now, ok. Commented May 22, 2022 at 20:35
  • Apologies for my poor showing in the code insert. It has been a while. Problem solved. I will explain. Commented May 23, 2022 at 16:44

1 Answer 1

0

As an update to this, I found the solution. Effectively, while I want to take an unstructured XML output and make it structured, it doesn't work like I thought.

It was necessary for me to take the single line of XML and format it as you see in the code markup. In the text file I lifted this from, I lifted a single line of XML which was not structured into multiple lines you see in stack overflow.

Thank you for your comments.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.