SOAP:在php中构建信封

时间:2015-05-14 20:57:33

标签: php soap

我想实现这个xml。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://eid.equifax.com/soap/schema/canada/v2">
<soapenv:Header/>
<soapenv:Body>
  <v2:InitialRequest>
     <v2:Identity>
        <v2:Name>
           <v2:FirstName>MILO</v2:FirstName>
           <v2:LastName>TESTADD</v2:LastName>
        </v2:Name>
        <!--1 to 3 repetitions:-->
        <v2:Address timeAtAddress="50" addressType="Current">
           <v2:HybridAddress>
              <v2:AddressLine>731 BAY AVE</v2:AddressLine>
              <v2:City>Kelowna</v2:City>
              <v2:Province>BC</v2:Province>
              <v2:PostalCode>V1Y7K2</v2:PostalCode>
           </v2:HybridAddress>
        </v2:Address>
        <v2:DateOfBirth>
           <v2:Day>03</v2:Day>
           <v2:Month>03</v2:Month>
           <v2:Year>1989</v2:Year>
        </v2:DateOfBirth>
     </v2:Identity>
     <v2:ProcessingOptions>
        <v2:Language>English</v2:Language>
     </v2:ProcessingOptions>
  </v2:InitialRequest>
</soapenv:Body>
</soapenv:Envelope>

所以,我创造了这个:

$all_names = array('FirstName'=>"PERFUME",
                       'LastName'=>"TESTSWEET");
    $all_addresses = array('AddressLine'=>"109 ALBERT ST NE",
                           'City'=>"AIRDRIE",
                           'Province'=>"AB",
                           'PostalCode'=>"T4B0R5"
                           );
    $hybrid_address = array('HybridAddress'=>$all_addresses);
    $dob = array('Day'=>"31",
                 'Month'=>"09",
                 'Year'=>"1972"
                 );
    $identity = array('Name'=>$all_names,
                      'Address'=>$hybrid_address,
                      'DateOfBirth'=>$dob
                      );
    $language = array('Language'=>'English');
    $initial_request = array('Identity'=>$identity,
                             'ProcessingOptions'=>$language
                             );

$test = $client->__call('startTransaction', array('initialRequest'=>$initial_request));

但是,我不知道,这里有什么不对。它给了我内部服务器错误。

PS:数据似乎有所不同,因为我是从不同来源复制的。

修改

[14-May-2015 17:02:03 America/Toronto] PHP Fatal error:  Uncaught SoapFault     exception: [soap:Server] Unexpected internal error in     D:\home\site\wwwroot\application\third_party\WSSoapClient.php:61
Stack trace:
#0 D:\home\site\wwwroot\application\third_party\WSSoapClient.php(61): SoapClient->__call('startTransactio...', Array)
#1 D:\home\site\wwwroot\application\controllers\equifax.php(58): WSSoapClient->__call('startTransactio...', Array)
#2 [internal function]: Equifax->verify()
#3 D:\home\site\wwwroot\system\core\CodeIgniter.php(359): call_user_func_array(Array, Array)
#4 D:\home\site\wwwroot\index.php(227): require_once('D:\\home\\site\\ww...')
#5 {main}
thrown in D:\home\site\wwwroot\application\third_party\WSSoapClient.php on     line 61

1 个答案:

答案 0 :(得分:0)

我一直试图让equifax工作几周。 支持线旁边没用。

您是否设置了编码?它的意思是UTF8。 同时在信封中获取命名空间也会阻止一些错误。 它从文档中发生了变化,文档中充满了拼写错误并且过时了。 包含标题的方式也有点温和,而不是根据文档