这里的想法是,我可以成功请求第一个,这给了我一个 ID,我必须将此 ID 用于第二个请求,但第二个如何?
try {
$clienteSOAP = new SoapClient ( 'someservicehere' );
$header = array('Username' => 'user', 'Password' => 'pass', 'DeviceType'=> 3,'Platform'=>'1');
$response = $clienteSOAP->GetSession($header);
//echo $response->SessionID:
//15987451
$header2 = array('Username' => 'user', 'Password' => 'pass','SessionID' => '15987451' , 'DeviceType'=> 3,'Platform'=>'1');
$clienteSOAP->GetBalance($header2);
//GetBalance throws error,
} catch ( SoapFault $e ) {
var_dump ( $e );
}
GetSession 的 xml,这很好用!!!
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ext="someTextHere">
<soapenv:Header/>
<soapenv:Body>
<ext:GetSessionRequest>
<ext:Username></ext:Username>
<ext:Password></ext:Password>
<ext:DeviceType></ext:DeviceType>
<!--Optional:-->
<ext:Platform></ext:Platform>
</ext:GetSessionRequest>
</soapenv:Body>
</soapenv:Envelope>
但为此,如何?
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ext="SomeTextHereToo">
<soapenv:Header/>
<soapenv:Body>
<ext:GetBalanceRequest>
<ext:AuthenticationData>
<!--Optional:-->
<ext:Username></ext:Username>
<!--Optional:-->
<ext:Password></ext:Password>
<!--Optional:-->
<ext:SessionID></ext:SessionID>
</ext:AuthenticationData>
<ext:DeviceType></ext:DeviceType>
<!--Optional:-->
<ext:Platform></ext:Platform>
</ext:GetBalanceRequest>
</soapenv:Body>
</soapenv:Envelope>