2

この問題を解決しようとして大きな問題を抱えているので、この仕事を手伝ってくれる人に+500の報奨金を与えたいと思います。

基本的に、私はNusoapを使用してこのWebサービスを呼び出そうとしています。

https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=QueryCustomer

これは私がこれまでに得たものです:

class Eway
{
    var $username = 'test@eway.com.au';
    var $pw = 'test123';
    var $customerId = '87654321';
    private function setHeaders($client)
    {
        $headers = <<<EOT
<eWAYHeader xmlns="http://www.eway.com.au/gateway/managedPayment">
      <eWAYCustomerID>$this->customerId</eWAYCustomerID>
      <Username>$this->username</Username>
      <Password>$this->pw</Password>
    </eWAYHeader> 
EOT;
       $client->setHeaders($headers);
       return $client;
    }

     function getCustomer($ewayId = 9876543211000)
     {
        $url = 'https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?WSDL';  
        $client = new Nusoap_client($url, true);
        $this->setHeaders($client);

        $args['QueryCustomer'] = array('managedCustomerID'=>$ewayId);

        $result = $client->call('QueryCustomer', $args);
        print_r($result);
    }
}

このコードを実行すると$eway->getCustomer()、次のエラーが発生しますか?

Array
(
    [faultcode] => soap:Client
    [faultstring] => eWayCustomerID, Username and Password needs to be specified in the soap header.
)

私は何が間違っているのですか?

私のクラスを修正し、テスト顧客IDを使用してQueryCustomerメソッドを実行し、その情報を返すことができる作業コードを提供していただければ、+500の担当者と私の永遠の感謝の気持ちをお伝えできることをうれしく思います。バウンティを開始できるようになるまでには明らかに48時間かかりますが、私はそれを行うことを約束します。

4

4 に答える 4

4

ポイントを逃している可能性がありますが、返されたオブジェクトを実際にに割り当てることはありません$client

function getCustomer($ewayId = 9876543211000)
 {
    $url = 'https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?WSDL';  
    $client = new Nusoap_client($url, true);
    $client = $this->setHeaders($client);

    $args['QueryCustomer'] = array('managedCustomerID'=>$ewayId);

    $result = $client->call('QueryCustomer', $args);
    print_r($result);
}

$client必要に応じて、またはパラメーターを参照として送信することにより、クラス変数として設定することもできます。


データを見ると、これが問題かどうかはわかりませんがvar、クラス変数宣言に使用privateしてから関数に使用しています。あなたがphp5を使用しているなら、私は遠ざかりますvar

private $username = 'test@eway.com.au';
private $pw = 'test123';
private $customerId = '87654321';

private一貫性を保つために、代わりにorpublicまたはprotected(クラスが必要とするもの) を使用してください。これがあなたの問題を解決するとは思えませんが、意識すべきことです。


考えられる解決策

わかりました、私自身の掘り下げを行って、これを理解しましたSOAP:Header。取引に追加する実際のヘッダーを囲む必要があります。私は以下をテストし、それは私のために働いていたので、試してみてください:

private function setHeaders($client)
{
    $headers = <<<EOT
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP:Header>
<eWAYHeader xmlns="http://www.eway.com.au/gateway/managedPayment">
  <eWAYCustomerID>$this->customerId</eWAYCustomerID>
  <Username>$this->username</Username>
  <Password>$this->pw</Password>
</eWAYHeader>
</SOAP:Header>
EOT;
   $client->setHeaders($headers);
   return $client;
}

エラーは返されませんでした。そうそう、それが犯人である可能性が高いようです。$client = $this->setHeaders($client);(上記のIも実装したことに注意してください。


そして、私の最終的な答えは次のとおりです。

さて、少し掘り下げて、うまくいくものを見つけました。それが正しいとは言いませんが、そうです。

private function setHeaders($client)
{
    $headers = <<<EOT
<eWAYHeader xmlns="https://www.eway.com.au/gateway/managedpayment">
  <eWAYCustomerID>$this->customerId</eWAYCustomerID>
  <Username>$this->username</Username>
  <Password>$this->pw</Password>
</eWAYHeader>
EOT;
   $client->setHeaders($headers);
   return $client;
}

 function getCustomer($ewayId = 123456789012)
 {
    $url = 'https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?WSDL';
    $client = new nusoap_client($url);
    $client = $this->setHeaders($client);

    $args['QueryCustomer'] = array('managedCustomerID'=>$ewayId);

    $result = $client->call('QueryCustomer', $args, $namespace='https://www.eway.com.au/gateway/managedpayment', $soapAction='https://www.eway.com.au/gateway/managedpayment/QueryCustomer');

    print_r($result);

    //echo "\n{$client->request}\n"; // This echos out the response you are sending for debugging.
}

namespacesoapActionが重要な成分だったようです。最初に投稿したリンクを使用してこれらを見つけました: https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?op=QueryCustomer

基本的に、私はその応答を見て、soapAction を把握するために検索を行い、送信された要求が投稿したページと一致するまでそれをいじりました。ログインの失敗を返しますが、そうです。これは通常、何かが機能していることを意味し、おそらくテスト データによるものです。しかし、それはあなたに出発するためのベースラインを与えます.

そして、$client->request将来のための便利なデバッグ ツールです。

于 2011-03-22T21:29:45.897 に答える
1

更新 5: nusoap は実際に次のSOAP-ENVようにリクエストをラップします。

<SOAP-ENV:Header><eWAYHeader xmlns="https://www.eway.com.au/gateway/managedpayment"> 
      <eWayCustomerID>87654321</eWayCustomerID> 
      <Username>test@eway.com.au</Username> 
      <Password>test123</Password> 
</eWAYHeader></SOAP-ENV:Header>

ドキュメントでは EWaysoap:Headerを使用する必要があります。nusoap ヘッダーで後者についての言及を見つけることができませんでした。

更新 4: このリンクには良いヒントがあります。

とった。ケースの問題でしたが、そこにはありませんでした。PDF は正しくありません。

将来これを取得する人のために、PDFには次のように記載されています。

<eWAYHeader xmlns="http://www.eway.com.au/gateway/managedPayment"> そのはず:

<eWAYHeader xmlns="https://www.eway.com.au/gateway/managedpayment">

于 2011-03-22T20:55:59.130 に答える
0

だからこれはここにあります:

$client->setHeaders($headers);

SoapClientクラスにはそのメソッドがありません。代わりに、を作成できますnew SoapHeader

private function setHeaders($client)
{
    $headers = new stdClass;
    $headers->eWAYCustomerID = $this->customerId;
    $headers->Username = $this->username;
    $headers->Password = $this->pw;


    $ewayHeader = new SoapHeader(
        "http://www.eway.com.au/gateway/managedPayment",
        "eWAYHeader",
        $headers
    );

   $client->__setSoapHeaders(array($ewayHeader));
   return $client;
}

編集:わかりました、深く掘り下げます:

private function prepHeaders()
{
    return array(
        'eWAYHeader' => array(
            'eWAYCustomerID' => $this->customerId,
            'Username' => $this->username,
            'Password' => $this->pw
        )
    );
}

 function getCustomer($ewayId = 9876543211000)
 {
    $url = 'https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?WSDL';  
    $client = new nusoap_client($url);

    $args['QueryCustomer'] = array('managedCustomerID'=>$ewayId);

    $result = $client->call('QueryCustomer', $args, null, null, $this->prepHeaders());
    print_r($result);
}

そうするとどうなりますか?

于 2011-03-22T21:02:37.760 に答える
0

これが問題の完全な解決策ではないことはわかっていますが、この質問はかなり古いものですが、私の調査結果が具体的な解決策につながる可能性があります.

HTTP "SOAPAction" ヘッダーについての言及に関連して、同様のエラーが発生しています。(ただし、私はあなたとは別の eWay API を扱っています。先週、「Merchant Hosted Payments」から名前が変更された「Rapid API」を扱っています。これが、私のスクリプトが「動作していません)。

要点に戻ると、HTTP の "SOAPAction" ヘッダーを指定しないと、eWay は次のエラー メッセージと共に SoapFault を返すことがわかりました。

「System.Web.Services.Protocols.SoapException: 有効なアクション パラメータがないと要求を処理できません。有効な SOAP アクションを指定してください。」

HTTP「SOAPAction」ヘッダーを追加すると、設定に関係なくエラーが発生します。

「System.Web.Services.Protocols.SoapException: サーバーは HTTP ヘッダー SOAPAction: XXX の値を認識しませんでした」

また、eWay のサポート スタッフのメンバーから、内部リダイレクトに問題があり、現在解決を検討しているとのことです。

<ME> (2012-05-25 02:50:18)
I had an idea of what it could be. What is the "SOAPAction" HTTP header supposed to be set to?

<ME> (2012-05-25 02:52:05)
I couldn't find it in the documentation.

<EWAY_SUPPORT_STAFF> (2012-05-25 02:53:38)
The only thing that is required typically is the endpoint which is https://au.ewaypayments.com/hotpotato/soap.asmx and the <CreateAccessCode xmlns="https://au.ewaypayments.com/hotpotato/">

<EWAY_SUPPORT_STAFF> (2012-05-25 02:54:10)
In my tests it is working but what is happening is that requests are being redirected to the old URL which does not accept the CreateAccessCode method

<ME> (2012-05-25 02:56:58)
You did say that.

<ME> (2012-05-25 02:57:13)
So is this bug happening in the production environment?

<EWAY_SUPPORT_STAFF> (2012-05-25 02:57:57)
Yes it appears so. I have escalated this to Development and attached our last chat transcript and my own test results. They are looking at it now.
于 2012-05-28T00:53:21.600 に答える