3

これは、ここのプロにとって簡単なものです。簡単な呼び出しを行うために、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>

実行すると、以下のエラーが発生します。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

私はまた、同様の問題に直面しているが解決策を見つけることができない人々からいくつかの読書をしました.

次のコードが機能するため、soapClientライブラリがアクティブになっていることは確かです

var_dump($client->__getFunctions());

出力:

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)

このエラーを解決するための助けと、エラーの考えられる説明は素晴らしいものです。

4

1 に答える 1

7

Internal Server Error通常、サーバーがリクエストを受け取ったが、パラメーターのいずれかが気に入らなかったことを意味します。

あなたの WSDL を見るCelciusToFahrenheitと、次の定義を持つ 1 つのパラメーターが期待されていることがわかります。

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

複合型はオブジェクトです。だからこれを試してください:

$SoapCallParameters = new stdClass();
$SoapCallParameters->nCelcius = 30;
$obj = $client->CelciusToFahrenheit($SoapCallParameters);
于 2013-09-13T21:00:41.293 に答える