2016-07-27 7 views
1

私は本当にこれが正しいタイトルを書いていたことを願っています。基本的に、私は特定のURLにSOAPリクエストを作成し、そこからデータを取得するために接続する必要があります。PHP SOAPがWSDLにエンベロープを送信

これは私が送信する必要が要求された:i __getTypes(呼び出すとき

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:rad="http://schemas.datacontract.org/2004/07/Radixx.ConnectPoint.Request" xmlns:rad1="http://schemas.datacontract.org/2004/07/Radixx.ConnectPoint.Security.Request"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <tem:RetrieveSecurityToken> 
     <!--Optional:--> 
     <tem:RetrieveSecurityTokenRequest> 
      <rad:CarrierCodes> 
       <!--Zero or more repetitions:--> 
       <rad:CarrierCode> 
        <rad:AccessibleCarrierCode>FZ</rad:AccessibleCarrierCode> 
       </rad:CarrierCode> 
      </rad:CarrierCodes> 
      <rad1:LogonID>xxx</rad1:LogonID> 
      <rad1:Password>xxxx</rad1:Password> 
     </tem:RetrieveSecurityTokenRequest> 
     </tem:RetrieveSecurityToken> 
    </soapenv:Body> 
</soapenv:Envelope> 

は、これは私のコード

$url = "http://uat.ops.connectpoint.flydubai.com/ConnectPoint.Security.svc?wsdl"; 
$data = array( "LogonID"=>"xxxxx", "Password"=>"xxxxx"); 

$client = new SoapClient($url); 

$client->__soapCall("RetrieveSecurityToken", $data); 

と要求エラー

Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'RetrieveSecurityToken'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 162. in J:\WORK\web\flyDubai\index.php:25 Stack trace: #0 J:\WORK\web\flyDubai\index.php(25): SoapClient->__soapCall('RetrieveSecurit...', Array) #1 {main} thrown in J:\WORK\web\flyDubai\index.php on line 25` 

である)私は(取得とりわけ、

struct RetrieveSecurityToken { 
    string LogonID; 
    string Password; 
} 

私はこの要求は正しいとは思わない(おそらく、私は全体のXMLを配列に変換して送信する必要があります)が正しいとは思いませんか?

答えて

0

呼び出すメソッドには、に定義されているRetrieveSecurityTokenタイプのパラメータRetrieveSecurityTokenRequestが必要です。そこには、CarrierInfoから、LogonIDPasswordのプロパティが追加されていることがわかります。

ベースタイプCarrierInfoは、XSD fileで定義されています。それはArrayOfCarrierCodeのタイプのCarrierCodesという単一のプロパティーを持っており、それぞれオブジェクトの配列であり、それぞれがAccessibleCarrierCodeという文字列プロパティを持っています。

CarrierInfoはnillable(<rad:CarrierCodes xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />)と指定されていますが、空の配列(<rad:CarrierCodes/>)でもかまいませんが、これらの場合はサービスでエラーが返されます。

あなたはおそらく、少なくとも一つのキャリアコードを有する、あなたが質問に投稿されたサンプルXML以下のリクエストを作成する必要がある理由だから、これは次のとおりです。

$code = new StdClass; 
$code->AccessibleCarrierCode = "FZ"; 

$data = new StdClass; 
$data->CarrierCodes = array($code); 

$data->LogonID = "xxxxx"; 
$data->Password = "xxxxx"; 

$client = new SoapClient($url); 
$response = $client->RetrieveSecurityToken(array("RetrieveSecurityTokenRequest" => $data)); 

var_dump($response); 
関連する問題