我正在尝试连接到具有肥皂1.2的.NET WCF服务。使用PHP soap-client。我收到消息了
SoapFault exception: [HTTP] Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'. in C:\wamp64\www\eZPackPlatform\catalog\phpsoap.php:32 Stack trace: #0 C:\wamp64\www\eZPackPlatform\catalog\phpsoap.php(32): SoapClient->__doRequest('__doRequest('__call('GetAllComponent...', Array) #3 {main}
当我检查发送的肥皂请求时,它看起来像这样
2000
SOAP-ENV是soap版本1.1。
我的PHP代码在下面,我在其中将soap版本指定为SOAP_1_2
<?php
//header("Content-Type: text/xml");
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClientDebug("https://services.plmpack.net/PLMPackService.svc?wsdl",
array('soap_version' => 'SOAP_1_2',
'location'=>'https://services.plmpack.net/PLMPackService.svc/secure',
'login' => 'guest',
'password' => 'guest_' ,
'trace' => true,
'exceptions' => true
));
if ($client != null){
echo "soap client created\n";
try{
$component_array = $client->GetAllComponents(array('index' => 0,
'length' => 200,
'number' => 0
));
print_r( $component_array );
} catch (SoapFault $exception) {
echo $exception;
}
}
class SoapClientDebug extends SoapClient
{
public function __doRequest($request, $location, $action, $version, $one_way = NULL)
{
file_put_contents('soap_log.txt', $request);
return parent::__doRequest($request, $location, $action, $version);
}
}