+ -
当前位置:首页 → 问答吧 → 关于php soap认证的问题

关于php soap认证的问题

时间:2011-08-29

来源:互联网

各位大牛们好,在下想请教一个问题,希望遇到此类问题的朋友给予指点,谢谢.       代码如下:
      
  1. $local_cert = "d:\webroot\soap\cert.pem";

  2. $ns = 'https://admin.jetpay-card.com/CreditAppV1.svc?wsdl';

  3. $client = new SoapClient($ns,
  4.     array(
  5.      'local_cert' => $local_cert,
  6.    
  7.     )
  8.   );

  9.         
  10. $params = array(
  11.                             'vendorId' => 'TestVend',
  12.                             'customerId'  => '104900',
  13.                             'authAmt'         =>'100',
  14.                             'currency'        => 'EUR'
  15.                         );

  16. $vem = $client->__soapCall('AuthorizeCredit',$params,null,$header);

  17. var_dump($vem);
复制代码


     但是运行后一直提示:An error occurred when verifying security for the message,也就是服务端认证错误。
     以下是服务器端给我提供的一个完整流程



POST https://admin.jetpay-card.com/CreditAppV1.svc HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.evo-jet.com/services/ICreditAppV1/AuthorizeCredit"
Host: admin.jetpay-card.com
Content-Length: 908
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <s:Header>
    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <u:Timestamp u:Id="_0">
        <u:Created>2011-08-24T18:14:50.876Z</u:Created>
        <u:Expires>2011-08-24T18:19:50.876Z</u:Expires>
      </u:Timestamp>
      <o:UsernameToken u:Id="uuid-8e6ad18f-7888-4790-a21c-b69fae46b6b8-1">
        <o:Username>put username here</o:Username>
        <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">put password here</o:Password>
      </o:UsernameToken>
    </o:Security>
  </s:Header>
  <s:Body>
    <AuthorizeCredit xmlns="http://www.evo-jet.com/services">
      <vendorId>TestVend</vendorId>
      <customerId>104900</customerId>
      <authAmt>100</authAmt>
      <currency>EUR</currency>
    </AuthorizeCredit>
  </s:Body>
</s:Envelope>
Server Response:

HTTP/1.1 200 OK
Content-Length: 749
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 24 Aug 2011 18:15:02 GMT

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <s:Header>
    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <u:Timestamp u:Id="_0">
        <u:Created>2011-08-24T18:15:02.627Z</u:Created>
        <u:Expires>2011-08-24T18:20:02.627Z</u:Expires>
      </u:Timestamp>
    </o:Security>
  </s:Header>
  <s:Body>
    <AuthorizeCreditResponse xmlns="http://www.evo-jet.com/services">
      <AuthorizeCreditResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <AuthCode i:nil="true"/>
        <AuthId>0</AuthId>
        <AuthResult>InvalidCustomer</AuthResult>
      </AuthorizeCreditResult>
    </AuthorizeCreditResponse>
  </s:Body>
</s:Envelope>[/code]

   我想应该是我构造SOAPHeader时出问题了,这PHP中这部分代码没有帖出来,但不知如何跟据以上去构造它。

作者: yangmao726   发布时间: 2011-08-29

等啊。

作者: yangmao726   发布时间: 2011-08-29

等啊。

作者: yangmao726   发布时间: 2011-08-29