Reputation: 20960
I'm going through tutorials on webservices and SOAP. In learning about these, I created a php file to act on the WSDL provided by w3schools that converts temperatures between Celsius and Fahrenheit.
I wrote the following PHP code which fires successfully:
$wsdl = "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL";
$soapClient = new SoapClient($wsdl);
// print_r ($soapClient->__getFunctions());
// print_r ($soapClient->__getTypes());
$parameters = array("Celsius" => "0");
$result = $soapClient->__soapCall("CelsiusToFahrenheit", array($parameters) );
echo "key: " . key($result) . "<br />" ;
echo "value: " . current($result) . "<br />" ;
The browser successfully returns the following:
key: CelsiusToFahrenheitResult
value: 32
I then tried to use the SoapClient methods __getLastRequest()
and __getLastRequestHeaders()
to take a look at the headers that were sent and see how they compare to what I had been reading and both method calls returned null
echo "Last call headers: <br />";
echo $soapClient->__getLastRequestHeaders();
echo "<br />" ;
echo "Last call headers: <br />";
echo $soapClient->__getLastRequest();
I reviewed the notes and example in the php manual for _getLastRequestHeaders() and it looks like everything is set up correctly. I can't tell what I'm doing wrong :/
Any help would be appreciated!
Upvotes: 2
Views: 3341
Reputation: 70490
If you don't set trace
to true in the options argument of the constructor of the SoapClient
, it won't store these. So simply put, this will work for you:
$soapClient = new SoapClient($wsdl, array('trace' => true));
... which the manual page you linked to explicitly states:
Note:
This function only works if the SoapClient object was created with the trace option set to TRUE.
Upvotes: 7