我们的要求是通过SOAP1.2发送请求。我在PHP中使用下面的代码。
$basic_auth = base64_encode(USERNAME.':'.PASSWORD);
$opts = array(
'http'=>array(
'header' => "Authorization: Basic $basic_auth
x-ibm-client-id: $client_id
x-ibm-client-secret: $client_secret"
)
);
$context = stream_context_create($opts);
$soap_client = new SoapClient(WSDL, array("trace"=>1,
"local_cert"=>"/var/www/cert.pem",
"passphrase"=>"xxxxx",
"soap_version"=>SOAP_1_2,
"exeptions"=>true,
"stream_context"=>$context,
"location"=>LOCATION
));
try{
$params = array(
'getBalance' => array(
'version' => 1,
'partnerCode'=>PARTNER_CODE
));
$post_response = $soap_client->__soapCall('getBalance', $params);
return $post_response;
}
catch(SoapFault $fault){
highlight_string($soap_client->__getLastRequestHeaders());
highlight_string($soap_client->__getLastRequest());
die("SOAP Fault: fault code: {$fault->faultcode}, fault string: {$fault->faultstring}");
}我正在收到的错误如下:
SOAP错误:错误代码: VersionMismatch,错误字符串:错误版本
如何检查天气请求是否实际使用了SOAP12?
发布于 2017-08-14 20:03:12
您可以通过检查请求XML来检查SOAP请求是否使用了正确的版本。请求之后,检查XML:
var_dump($soap_client->__getLastRequest());注意信封声明中使用的命名空间。
SOAP1.2:http://www.w3.org/2003/05/soap-envelope
SOAP1.1 http://schemas.xmlsoap.org/soap/envelope/
https://stackoverflow.com/questions/45640917
复制相似问题