这里有没有人尝试过使用 php curl 或soapClient 连接到实现 .net 二进制编码( http://msdn.microsoft.com/en-us/library/cc219175.aspx )的 SOAP 服务器。 当我尝试使用curl连接到url时,我总是收到400错误请求,因为我需要将xml转换为某种.net二进制格式
谢谢...
示例代码
$soap_request =“ ”;
$url = 'https://webapp.healthcaresynergy.com:8002/demoalpha/HealthCareServiceWCF.svc?singleWsdl';
$header = array(
'Content-type: application/soap+msbin1',
'Expect: ',
'SOAPAction: urn:HealthCareServiceWCF/Login',
'Content-length: '.strlen($soap_request),
);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_RETURNTRANSFER => true,
//CURLOPT_ENCODING => 'gzip',
CURLOPT_HEADER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)',
//CURLOPT_VERBOSE => true,
//CURLOPT_STDERR => $verbose = fopen('php://temp', 'rw+'),
CURLOPT_URL => $url ,
CURLOPT_POSTFIELDS => 1,
CURLOPT_POSTFIELDS => $soap_request,
CURLOPT_HTTPHEADER => $header ,
CURLOPT_CUSTOMREQUEST => 'POST'
));
$output = curl_exec($ch);
$info = curl_getinfo($ch);
if($output === false) {
$err = 'Curl error: ' . curl_error($ch);
} else {
echo 'Operation success';
} echo '<pre>';
print_r($info);
//echo "Verbose information:\n<pre>", !rewind($verbose), htmlspecialchars(stream_get_contents($verbose)), "</pre>\n";
curl_close($ch);
$s = htmlspecialchars($output);
echo $s;
最佳答案
这让我想起了我们对MSNP(Windows Live Messenger)进行逆向工程的时候。您需要将 SOAP 翻译为 their bytestream format .
这是一个适合您的库:
https://github.com/casperbiering/phpBinaryXml
更新:
Known/Missing issues:
- only decoding is supported
我真是个傻子。我会留下答案,也许在搜索编码库时会有帮助。
也许解决方法是编译一个 .NET 控制台程序或类似的 Linux 程序,并将其用作包装器/转换器。
关于php xml 到 .NET 二进制格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24765366/