1

I am trying to interact with a .NET web service through PHP. I'm able to connect to the service, I'm able to call getFunctions and it returns a list of all the service functions. I have used soapUI to test out the web service, and all the requests work flawlessly when I use soapUI.

However, whenever I use PHP to call one of the service functions, I get a seemingly empty response.

Code:

$client = new SoapClient("http://soapservice.com/soap.asmx?WSDL");

$params = array();

$params["userName"] = 'myUserName';     
$params["password"] = 'somePass1234';   

$locations = $client->GetStuff($params);

var_dump($locations);

$locations = $client->GetStuff($params)->GetStuffResult;    

var_dump($locations);

The output of the var dumps is as follows:

object(stdClass)#35 (1) {
  ["GetStuffResult"]=>
  string(835807) ""
}
string(835807) ""

The first question I have is... how can an "empty" string be 835807 chars long? My second and more obvious question is where is the data and why can't I access it? soapUI shows that the response is in XML, but I am seeing absolutely nothing of use in this response string. Please help!

1 Answer 1

2

If $location contains XML then chances are the output is correct but won't be "shown" in your browser (unless a content-type header like text/plain is sent) because your browser doesn't show (what it thinks to be) tags/elements. You need to encode the "XML string" in $location containing, for example, <foo> to &lt;foo&gt;. Try:

echo htmlentities(print_r($locations, true));

...or:

header("Content-Type: text/plain");
var_dump($locations);

...or just "view source" in your browser.

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

1 Comment

This is exactly what I needed... can't believe all I had to do was view source!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.