【发布时间】:2011-11-06 18:16:42
【问题描述】:
我一直在尝试执行 XML 请求。我遇到了很多问题,我设法解决了。但是这个我解决不了。 这是脚本:
$url ="WebServiceUrl";
$xml="XmlRequest";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
它给了我这个错误:
System.InvalidOperationException:请求格式无效:text/xml。在 System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() 在 System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
我还是个菜鸟。所以对我放轻松:) 谢谢。
【问题讨论】:
-
谁能帮我解决这个问题?
-
如果是WSDL使用
SoapClient,如果你需要使用这种代码风格,检查应该请求什么格式(并删除text/xmlcontent-type) -
我怎么知道请求应该是什么格式?
-
来自地址,通常以
.wsdl结尾,但我更愿意学习SoapClient (php.net/manual/en/soapclient.soapclient.php)
标签: php xml curl xmlhttprequest