运行soapclient时出现内部服务器错误

Abh*_*ana 2 php soap-client

这对于专业人士来说应该是一个简单的方法.我正在使用soapClient php库进行简单的调用(参见下面的代码).

    <?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>
Run Code Online (Sandbox Code Playgroud)

当我执行时,我得到以下错误.我查看了Apache错误日志,我看到了同样的错误.

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
Run Code Online (Sandbox Code Playgroud)

我也从面临类似问题但未能找到解决方案的人那里做了一些阅读.

我确信soapClient库已激活,因为以下代码有效

var_dump($client->__getFunctions());
Run Code Online (Sandbox Code Playgroud)

输出:

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)
Run Code Online (Sandbox Code Playgroud)

任何帮助解决此错误和错误的可能解释将是伟大的.

Ser*_*hiv 6

Internal Server Error 通常意味着服务器得到了您的请求,但它不喜欢其中一个参数.

看看你的WSDL,我可以看到CelciusToFahrenheit一个带有这个定义的参数:

<xs:complexType>
 <xs:sequence>
    <xs:element name="nCelcius" type="xs:decimal"/>
 </xs:sequence>
</xs:complexType>
Run Code Online (Sandbox Code Playgroud)

复杂类型是一个对象.试试这个:

$SoapCallParameters = new stdClass();
$SoapCallParameters->nCelcius = 30;
$obj = $client->CelciusToFahrenheit($SoapCallParameters);
Run Code Online (Sandbox Code Playgroud)