-1

Edited post requested by Michael.

$Response = $soapClient->__getLastResponse();
$pos = strpos($Response, ">");
echo substr($Response, $pos+1);
// Returns soap:ReceiverServer was unable to process request. ---> Product already exists

$Response = $soapClient->__getLastResponse();
$converted = (string)$Response
$pos = strpos($converted, ">");
echo substr($converted, $pos+1);
// Returns soap:ReceiverServer was unable to process request. ---> Product already exists

I am using an API and wanting to use the response as an error message. The response looks like the following:

soap:ReceiverServer was unable to process request. ---> Product already exists

I am trying to remove everything before Product so I just have the error message to display to a user. However when I use this, I get the following in return.

>soap:ReceiverServer was unable to process request. ---> Product already exists

This is the code I am currently using. Does anybody have any suggestions?

$Response = $soapClient->__getLastResponse();
echo $Response;
// Shows the below
// soap:ReceiverServer was unable to process request. ---> Product already exists

$test =  strstr($Response, '>');
echo '<br>'
echo $test;
// Shows the below
// >soap:ReceiverServer was unable to process request. ---> Product already exists
Jake
  • 141
  • 3
  • 12

1 Answers1

0
$Response = "soap:ReceiverServer was unable to process request. --- >   Product already exists";
$pos = strpos($Response, ">");
echo substr($Response, $pos+1);
Michael
  • 405
  • 4
  • 10
  • Hi @Michael this returns the following `soap:ReceiverServer was unable to process request. ---> Product already exists` – Jake Dec 22 '16 at 12:46
  • That's strange... Take a look at the php sandbox: http://sandbox.onlinephpfunctions.com/code/0a239f502623c69f88d81a2f0c74e665f3d55171 – Michael Dec 22 '16 at 12:49
  • Can you paste your code with the modifications I suggested? – Michael Dec 22 '16 at 12:52
  • sure, edited first post. I'v added two versions (one I tried to force into a string). – Jake Dec 22 '16 at 13:03
  • You need to put a ";" at the end of your statements. Your $Response is string, right? Can you post the rest of your code? This should work with the info you provided. Did you try the link to the php sandbox? – Michael Dec 23 '16 at 07:25