php 卷曲与肥皂错误:无法处理没有有效操作参数的请求
我通过 php 中的curl 发送肥皂请求,并得到以下响应:
客户端无法处理没有有效操作参数的请求。 请提供有效的肥皂操作。
SOAP XML:
$url="http://www.site.com/soap.asmx";
$user = "test";
$password = "test";
$post_string = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<Routing xmlns="www.site.com">
<Login>test</Login>
<Password>testy</Password>
</Routing>
</soap:Header>
<soap:Body>
</soap:Body>
</soap:Envelope>';
卷曲:
$soapme = curl_init();
curl_setopt($soapme, CURLOPT_URL, $url );
curl_setopt($soapme, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soapme, CURLOPT_TIMEOUT, 10);
curl_setopt($soapme, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soapme, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soapme, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soapme, CURLOPT_POST, true );
curl_setopt($soapme, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($soapme, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($post_string) ));
curl_setopt($soapme, CURLOPT_USERPWD, $user . ":" . $password);
curl_setopt($soapme, curlOPT_VERBOSE, 1);
curl_exec($soapme);
I am sending a soap request via curl in php, and I get this response:
Client Unable to handle request without a valid action parameter.
Please supply a valid soap action.
SOAP XML:
$url="http://www.site.com/soap.asmx";
$user = "test";
$password = "test";
$post_string = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<Routing xmlns="www.site.com">
<Login>test</Login>
<Password>testy</Password>
</Routing>
</soap:Header>
<soap:Body>
</soap:Body>
</soap:Envelope>';
CURL:
$soapme = curl_init();
curl_setopt($soapme, CURLOPT_URL, $url );
curl_setopt($soapme, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soapme, CURLOPT_TIMEOUT, 10);
curl_setopt($soapme, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soapme, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soapme, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soapme, CURLOPT_POST, true );
curl_setopt($soapme, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($soapme, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($post_string) ));
curl_setopt($soapme, CURLOPT_USERPWD, $user . ":" . $password);
curl_setopt($soapme, curlOPT_VERBOSE, 1);
curl_exec($soapme);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果无法看到 SOAP Web 服务期望的并由 WSDL 定义的实际消息和操作类型,那么我可以打赌您的 Headers 行缺少 SOAP 1.1 SOAPAction 标头:
请注意,我调用了 SOAPAction 路由,但它实际上可以是任何东西,具体取决于前面提到的 Web 服务期望的内容和 WSDL 定义的内容。
Without being able to see the actual message and action types expected by the SOAP Web Service and defined by the WSDL, then I can wager a bet that your Headers line is missing the SOAP 1.1 SOAPAction header:
Please note, I called the SOAPAction Routing but it really could be anything, depending as mentioned, on what the Web Service expects and WSDL defines.