internal server error when running soapclient

2019-05-26 10:18发布

This should be an easy one for the pros here. I am using the soapClient php library to make a simple call(see code below).

    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
        $url = "http://webservices.daehosting.com/services/TemperatureConversions.wso?WSDL";

        $client = new SoapClient($url, array("trace" => 1, "exception" => 0)); 

        var_dump($client->__getFunctions());

        $SOAPCall = "CelciusToFahrenheit";
        $SoapCallParameters = "30";
        $obj = $client->CelciusToFahrenheit($SoapCallParameters);
        var_dump($obj);

        var_dump($client->getLastRequest());
    ?>

</body>

When i execute i get the below error. I have looked in the Apache error logs and I see the same error.

Fatal error: Uncaught SoapFault exception: [HTTP] Internal Server Error in C:\wamp\www\phpSandbox\index.php:16 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://webservi...', '', 1, 0) #1 C:\wamp\www\phpSandbox\index.php(16): SoapClient->__call('CelciusToFahren...', Array) #2 C:\wamp\www\phpSandbox\index.php(16): SoapClient->CelciusToFahrenheit('30') #3 {main} thrown in C:\wamp\www\phpSandbox\index.php on line 16

I have also done some reading from people facing similar problems but not able to find a solution.

I know for sure that the soapClient library is activated because the following code work

var_dump($client->__getFunctions());

output:

array (size=4)
  0 => string 'CelciusToFahrenheitResponse CelciusToFahrenheit(CelciusToFahrenheit $parameters)' (length=80)
  1 => string 'FahrenheitToCelciusResponse FahrenheitToCelcius(FahrenheitToCelcius $parameters)' (length=80)
  2 => string 'WindChillInCelciusResponse WindChillInCelcius(WindChillInCelcius $parameters)' (length=77)
  3 => string 'WindChillInFahrenheitResponse WindChillInFahrenheit(WindChillInFahrenheit $parameters)' (length=86)

any help to resolve this error and possible explanation for the error will be great.

1条回答
We Are One
2楼-- · 2019-05-26 10:36

Internal Server Error usually means the server got your request but it did not like one of the parameters.

Lookin at your WSDL I can see CelciusToFahrenheit expects one parameter with this definition:

<xs:complexType>
 <xs:sequence>
    <xs:element name="nCelcius" type="xs:decimal"/>
 </xs:sequence>
</xs:complexType>

A complex type is an object. So try this:

$SoapCallParameters = new stdClass();
$SoapCallParameters->nCelcius = 30;
$obj = $client->CelciusToFahrenheit($SoapCallParameters);
查看更多
登录 后发表回答