0

PHP SOAP クライアントを使用して Web サービスからデータを取得しようとしましたが、SOAP 障害が発生しました

SoapFault Object (
    [message:protected] => Server was unable to process request. ---> There was an error generating the XML document. ---> <>f__AnonymousType2a`2[System.String,System.Object[]] cannot be serialized because it does not have a parameterless constructor. 
    [string:Exception:private] => 
        [code:protected] => 0
        [file:protected] => /Users/resarahman/Documents/xampp/htdocs/testing/soap/test.php
        [line:protected] => 17
        [trace:Exception:private] => Array ( 
            [0] => Array ( 
                [file] => /Users/resarahman/Documents/xampp/htdocs/testing/soap/test.php 
                [line] => 17 
                [function] => __call 
                [class] => SoapClient 
                [type] => -> 
                [args] => Array ( 
                    [0] => GetPublicSalesBanners 
                    [1] => Array ( 
                        [0] => Array ( 
                            [saleCategoryID] => 40F80218-A9E1-43C4-96FF-4C046D192A21 
                            [countryID] => AS 
                            [languageID] => EN 
                            [getTopThree] => 1 
                        ) 
                    ) 
                ) 
            ) 
            [1] => Array ( 
                [file] => /Users/resarahman/Documents/xampp/htdocs/testing/soap/test.php 
                [line] => 17 
                [function] => GetPublicSalesBanners 
                [class] => SoapClient 
                [type] => -> 
                [args] => Array ( 
                    [0] => Array ( 
                        [saleCategoryID] => 40F80218-A9E1-43C4-96FF-4C046D192A21 
                        [countryID] => AS 
                        [languageID] => EN 
                        [getTopThree] => 1 
                    ) 
                ) 
            ) 
        ) 
        [previous:Exception:private] => 
        [faultstring] => Server was unable to process request. ---> There was an error generating the XML document. ---> <>f__AnonymousType2a`2[System.String,System.Object[]] cannot be serialized because it does not have a parameterless constructor. 
        [faultcode] => soap:Server 
        [detail] => )

リクエストとレスポンス

リクエスト :

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.ozsale.com.au/API/V2">
    <SOAP-ENV:Body>
        <ns1:GetPublicSalesBanners>
            <ns1:saleCategoryID>40F80218-A9E1-43C4-96FF-4C046D192A21</ns1:saleCategoryID>
            <ns1:countryID>AS</ns1:countryID>
            <ns1:languageID>EN</ns1:languageID>
            <ns1:getTopThree>true</ns1:getTopThree>
        </ns1:GetPublicSalesBanners>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

応答:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <soap:Fault>
            <faultcode>soap:Server</faultcode>
            <faultstring>Server was unable to process request. ---&gt; There was an error generating the XML document. ---&gt; &lt;&gt;f__AnonymousType2a`2[System.String,System.Object[]] cannot be serialized because it does not have a parameterless constructor.</faultstring>
            <detail />
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

これまでの私のコードは次のとおりです。

<?php
// create a connection to the local host mono .NET pull back the wsdl to get the functions names
  // and also the parameters and return values
  $client = new SoapClient("http://www.ozsale.com.au/api/v2/api.asmx?WSDL",
    array(
      "trace"      => 1,    // enable trace to view what is happening
      "exceptions" => 0,    // disable exceptions
      "cache_wsdl" => 0) 
  );

  // get a response from the WSDL zend server function getQuote for the day monday
  $data = $client->GetPublicSalesBanners(array(
    'saleCategoryID' => '40F80218-A9E1-43C4-96FF-4C046D192A21',
    'countryID'=> 'AS',
    'languageID'=> 'EN', 
    'getTopThree' =>'1'
  ));

  print_r($data);

  // display what was sent to the server (the request)
  echo "<p>Request :".htmlspecialchars($client->__getLastRequest()) ."</p>";
  // display the response from the server
  echo "<p>Response:".htmlspecialchars($client->__getLastResponse())."</p>";
  ?>

API に関するドキュメントは、http: //www.ozsale.com.au/API/V2/api.asmx?op=GetPublicSalesBanners にあります。

ここで何が悪いのか誰にも分かりますか? それは私のコードですか、それともウェブサービスの問題ですか?

4

2 に答える 2

1

それは彼らの終わりのエラーのようです。そこで試してみるためにsoapUIを実行したところ、まったく同じエラーが発生しました。

また、エラーは PHP エラー (クライアント側 - あなたのもの) ではなく、ASP エラー (サーバー側) のようです。

サポートに連絡してください (サポートがあると仮定します)。

編集:さらに、国が以前と同じエラーを生成したGetPublicSalesCategoriesだけで、使用 する他のパブリックメソッドの1つをいじっていました。ただし、に変更したり、エラーが発生しない場合 (有用なデータは得られませんが、応答です。countryIDlangaugeIDAScountryIDAUUS<result>true</result>

おそらくあなたの国コードASは無効ですか?

于 2012-04-17T04:50:56.883 に答える
0

That stuff about System.String and System.Object look suspiciously like .NET errors and are probably on the server end (not your fault).

于 2012-04-17T04:47:18.657 に答える