2

以下に、サーバーと通信しようとしている PHP クライアントのスタック トレースを含めます。クライアントとサーバーの両方が WSDL ファイル file を読み込むため、その部分は問題ありません。

2 番目のスタック トレース配列項目でわかるように、2 次元配列を渡していますが、SoapServer がその__doRequest()機能を実行すると、配列は 1 つの管理不能な文字列に連結されます。これを修正する方法についての解決策は大歓迎です。

Internal Server ErrorArray
(
[0] => Array
    (
        [function] => __doRequest
        [class] => SoapClient
        [type] => ->
        [args] => Array
            (
                [0] => 
1Colby Meiertruetrue5510.517.55601000250020100151502015302000true10false0true23true12false152002020023.51031000.345231003.25520152.45258.52011.255152012

                [1] => http://192.168.1.120/test_soap/Client_Billing.php
                [2] => 
                [3] => 1
                [4] => 0
            )

    )

[1] => Array
    (
        [file] => /var/www/test_soap/client_avid_new.php
        [line] => 92
        [function] => __call
        [class] => SoapClient
        [type] => ->
        [args] => Array
            (
                [0] => CreatePlan
                [1] => Array
                    (
                        [0] => Array
                            (
                                [session-id] => 1
                                [plan] => Array
                                    (
                                        [name] => Colby Meier
                                        [is-public] => 1
                                        [active] => 1
                                        [country-id] => 5
                                        [setup-fee] => 5
                                        [base-rate] => 10.5
                                        [quarterly-per-month-rate] => 17.5
                                        [bi-annual-per-month-rate] => 56
                                        [annual-per-month-rate] => 0
                                        [blast-limit] => 1000
                                        [social-limit] => 2500
                                        [keyword-limit] => 20
                                        [vote-limit] => 100
                                        [auto-response-limit] => 15
                                        [text-2-screen-limit] => 150
                                        [survey-limit] => 20
                                        [trivia-limit] => 15
                                        [text-2-win-limit] => 30
                                        [mobile-website-limit] => 2000
                                        [enable-ftp] => 1
                                        [ftp-fee] => 10
                                        [enable-contact-manager] => 
                                        [contact-manager-fee] => 0
                                        [enable-mobile-website] => 1
                                        [mobile-website-fee] => 23
                                        [enable-listrak] => 1
                                        [listrak-fee] => 12
                                        [enable-url-qr] => 
                                        [url-qr-fee] => 15
                                        [mt-quota] => 200
                                        [mt-overage] => 20
                                        [mo-quota] => 200
                                        [mo-overage] => 23.5
                                        [keyword-quota] => 10
                                        [keyword-overage] => 3
                                        [mobile-website-quota] => 100
                                        [mobile-website-overage] => 0.3
                                        [keyword-campaign-quota] => 45
                                        [keyword-campaign-overage] => 23
                                        [vote-quota] => 100
                                        [vote-overage] => 3.25
                                        [auto-response-quota] => 5
                                        [auto-response-overage] => 20
                                        [text-2-screen-quota] => 15
                                        [text-2-screen-overage] => 2.45
                                        [survey-quota] => 25
                                        [survey-overage] => 8.5
                                        [trivia-quota] => 20
                                        [trivia-overage] => 11.25
                                        [text-2-win-quota] => 5
                                        [text-2-win-overage] => 15
                                        [social-quota] => 20
                                        [social-overage] => 12
                                    )

                            )

                    )

            )

    )

[2] => Array
    (
        [file] => /var/www/test_soap/client_avid_new.php
        [line] => 92
        [function] => CreatePlan
        [class] => SoapClient
        [type] => ->
        [args] => Array
            (
                [0] => Array
                    (
                        [session-id] => 1
                        [plan] => Array
                            (
                                [name] => Colby Meier
                                [is-public] => 1
                                [active] => 1
                                [country-id] => 5
                                [setup-fee] => 5
                                [base-rate] => 10.5
                                [quarterly-per-month-rate] => 17.5
                                [bi-annual-per-month-rate] => 56
                                [annual-per-month-rate] => 0
                                [blast-limit] => 1000
                                [social-limit] => 2500
                                [keyword-limit] => 20
                                [vote-limit] => 100
                                [auto-response-limit] => 15
                                [text-2-screen-limit] => 150
                                [survey-limit] => 20
                                [trivia-limit] => 15
                                [text-2-win-limit] => 30
                                [mobile-website-limit] => 2000
                                [enable-ftp] => 1
                                [ftp-fee] => 10
                                [enable-contact-manager] => 
                                [contact-manager-fee] => 0
                                [enable-mobile-website] => 1
                                [mobile-website-fee] => 23
                                [enable-listrak] => 1
                                [listrak-fee] => 12
                                [enable-url-qr] => 
                                [url-qr-fee] => 15
                                [mt-quota] => 200
                                [mt-overage] => 20
                                [mo-quota] => 200
                                [mo-overage] => 23.5
                                [keyword-quota] => 10
                                [keyword-overage] => 3
                                [mobile-website-quota] => 100
                                [mobile-website-overage] => 0.3
                                [keyword-campaign-quota] => 45
                                [keyword-campaign-overage] => 23
                                [vote-quota] => 100
                                [vote-overage] => 3.25
                                [auto-response-quota] => 5
                                [auto-response-overage] => 20
                                [text-2-screen-quota] => 15
                                [text-2-screen-overage] => 2.45
                                [survey-quota] => 25
                                [survey-overage] => 8.5
                                [trivia-quota] => 20
                                [trivia-overage] => 11.25
                                [text-2-win-quota] => 5
                                [text-2-win-overage] => 15
                                [social-quota] => 20
                                [social-overage] => 12
                            )

                    )

            )

    )

)

クライアントを呼び出すコードは次のとおりです。

$test = $client->CreatePlan(array("session-id"=>"1", "plan"=>$pa)); //$pa variable shown in stack trace

サーバー上の関連コードは次のとおりです。

 public function _checkArguments($arguments, $validParameters) {
    $variables = "";
    foreach ($arguments as $arg) {
        $type = gettype($arg);
        echo "type is ".$type;
        if ($type == "object") {
            $type = get_class($arg);
        }
        $variables .= "(".$type.")";
    }
    if (!in_array($variables, $validParameters)) {
        throw new Exception("Invalid parameter types: ".str_replace(")(", ", ", $variables));
    }
    return true;
}

/**
 * Service Call: CreatePlan
 * Parameter options:
 * (CreatePlan) parameters
 * @param mixed,... See function description for parameter options
 * @return CreatePlanResponse
 * @throws Exception invalid function signature messages
 */
public function CreatePlan($mixed = null) {
    $validParameters = array(
        "(CreatePlan)",
    );
    $args = func_get_args();
    echo "<pre>Args are: ".print_r($args)."</pre>";

    $this->_checkArguments($args, $validParameters);
    return $this->__soapCall("CreatePlan", $args);
}

ご想像のとおり、関数は で失敗しますfunc_get_args()。これは、過去数日間、私を完全に狂わせてきたので、アドバイスをいただければ幸いです.

編集:私がそれが失敗すると言うとき、func_get_args私はnull変数を返すことを意味します。したがって、 の場合$args = func_get_args()$argsnull です。

編集 2 : 問題の解決に役立つ場合は、Apache サーバーのログからのエラーを次に示します。

[error] [client 192.168.1.120] PHP Fatal error: Uncaught exception 'Exception' with message 'Invalid parameter types: (stdClass)' in /var/www/test_soap/Client_Billing.php:2200\nStack trace:\n#0 /var/www/test_soap/Client_Billing.php(2220): Client_Billing->_checkArguments(Array, Array)\n#1 [internal function]: Client_Billing->CreatePlan(Object(stdClass))\n#2 /var/www/test_soap/Client_Billing.php(2642): SoapServer->handle()\n#3 {main}\n thrown in /var/www/test_soap/Client_Billing.php on line 2200

編集 3 : 要求に従って、関連するタイプの WSDL スニペットを次に示します。

<complexType name="CreatePlanType"><!-- ns__CreatePlanType -->

   <sequence>
     <element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::name -->
     <element name="is-public" type="xsd:boolean" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::is_public -->
     <element name="active" type="xsd:boolean" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::active -->
     <element name="country-id" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::country_id -->
     <element name="setup-fee" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::setup_fee -->
     <element name="base-rate" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::base_rate -->
     <element name="quarterly-per-month-rate" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::quarterly_per_month_rate -->
     <element name="bi-annual-per-month-rate" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::bi_annual_per_month_rate -->
     <element name="annual-per-month-rate" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::annual_per_month_rate -->
     <element name="blast-limit" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::blast_limit -->
     <element name="social-limit" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::social_limit -->
     <element name="keyword-limit" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::keyword_limit -->
     <element name="vote-limit" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::vote_limit -->
     <element name="auto-response-limit" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::auto_response_limit -->
     <element name="text-2-screen-limit" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::text_2_screen_limit -->
     <element name="survey-limit" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::survey_limit -->
     <element name="trivia-limit" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::trivia_limit -->
     <element name="text-2-win-limit" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::text_2_win_limit -->
     <element name="mobile-website-limit" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::mobile_website_limit -->
     <element name="enable-ftp" type="xsd:boolean" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::enable_ftp -->
     <element name="ftp-fee" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::ftp_fee -->
     <element name="enable-contact-manager" type="xsd:boolean" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::enable_contact_manager -->
     <element name="contact-manager-fee" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::contact_manager_fee -->
     <element name="enable-mobile-website" type="xsd:boolean" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::enable_mobile_website -->
     <element name="mobile-website-fee" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::mobile_website_fee -->
     <element name="enable-listrak" type="xsd:boolean" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::enable_listrak -->
     <element name="listrak-fee" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::listrak_fee -->
     <element name="enable-url-qr" type="xsd:boolean" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::enable_url_qr -->
     <element name="url-qr-fee" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::url_qr_fee -->
     <element name="mt-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::mt_quota -->
     <element name="mt-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::mt_overage -->
     <element name="mo-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::mo_quota -->
     <element name="mo-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::mo_overage -->
     <element name="keyword-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::keyword_quota -->
     <element name="keyword-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::keyword_overage -->
     <element name="mobile-website-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::mobile_website_quota -->
     <element name="mobile-website-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::mobile_website_overage -->
     <element name="keyword-campaign-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::keyword_campaign_quota -->
     <element name="keyword-campaign-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::keyword_campaign_overage -->
     <element name="vote-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::vote_quota -->
     <element name="vote-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::vote_overage -->
     <element name="auto-response-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::auto_response_quota -->
     <element name="auto-response-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::auto_response_overage -->
     <element name="text-2-screen-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::text_2_screen_quota -->
     <element name="text-2-screen-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::text_2_screen_overage -->
     <element name="survey-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::survey_quota -->
     <element name="survey-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::survey_overage -->
     <element name="trivia-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::trivia_quota -->
     <element name="trivia-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::trivia_overage -->
     <element name="text-2-win-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::text_2_win_quota -->
     <element name="text-2-win-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::text_2_win_overage -->
     <element name="social-quota" type="xsd:int" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::social_quota -->
     <element name="social-overage" type="xsd:float" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlanType::social_overage -->
   </sequence>
  </complexType>
<element name="CreatePlan">
   <complexType>
    <sequence>
     <element name="session-id" type="xsd:string" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlan::session_id -->
     <element name="plan" type="ns:CreatePlanType" minOccurs="1" maxOccurs="1"/><!-- ns__CreatePlan::plan -->
    </sequence>
   </complexType>
  </element>

SOAP サーバーを実行するコード:

$server = new SoapServer("http://192.168.1.120/Client_Billing.wsdl");
$server->setClass("Client_Billing");
$server->handle();
4

5 に答える 5

1

var_dump()ブラウザで出力を使用して見ていますか? 実際に存在する XML タグをブラウザが隠している可能性があります。ページの「ソースの表示」を試してください。

于 2013-01-22T22:03:24.260 に答える
0

私の経験では、PHPでのWebサービスのデバッグは苦痛です...しかし、可能であれば、私はあなたにいくつかの助けを与えるように努めます。

使用しているWSDLInterpreterは何ですか?それは、クライアントを作成するときに追加のことを行うためだけに開発したサードパーティのクラスまたはラッパーですか?SoapClientを使用していない理由はありますか?

送信する配列を、WSDLで使用および言及しているクラスのオブジェクトの実際のインスタンスに置き換えてみましたか?

于 2013-01-29T11:11:15.780 に答える
0

したがって、誰かがまだこのスレッドをフォローしている場合に備えて。私はその問題が何であるかを知り、私もそれを見なかったという完全な馬鹿ではないと言えればいいのですが、私は嘘をつく習慣をつける傾向がありません。

全体の問題は、私の「サーバー」クラスが「クライアント」クラスを拡張__soapCall()し、soap呼び出し自体の中から再帰的に呼び出していたという事実から生じました。

于 2013-01-29T23:07:42.150 に答える
0

SOAP と PHP で何度も問題が発生した後、次の方法を使用してデバッグします。最初に応答をエコーし​​てみます。

echo htmlentities(var_dump($test,true));

何もない場合は、このステップに進みます。soap エラーを見つける最善の方法は、sniffer と soapUI を使用して、soap UI をインストールすることです。次に、最初のプロジェクトを作成するのは非常に簡単です: http://www.soapui.org/Getting-Started/your- first-soapui-project.html

パケット スニファーをインストールする

プロジェクトを作成して WSDL を入力すると、SOAP サービス メソッドを呼び出すことができます。これらのメソッドを呼び出すときは、パラメーターを手動で入力する必要があります。それらを入力して関数を実行し、正常に実行される場合は、PHP 側のどこかにエラーがあるか、HTML コメントに隠されていることを意味します。エラーがどこにあるかをよりよく理解するには、sniffer を使用して SOAP サービスから取得した応答をキャッチし、sniffer を実行する必要があります。次に、取得した出力を分析する必要があります。

于 2013-01-28T09:30:57.147 に答える
0

PHP SoapServer の動的オブジェクトの特殊なサポートに引っかかったと思います。可能であれば、配列を説明されているクラスに置き換えてみてください。

于 2013-01-28T08:39:45.933 に答える