[英]php curl with soap error: unable to handle request without valid action parameter
I am sending a soap request via curl in php, and I get this response: 我通过curl在php中发送了一个soap请求,并且得到了以下响应:
Client Unable to handle request without a valid action parameter. 客户端如果没有有效的操作参数,则无法处理请求。 Please supply a valid soap action. 请提供有效的肥皂动作。
SOAP XML: 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);
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: 在无法看到SOAP Web Service期望和WSDL定义的实际消息和操作类型的情况下,我敢打赌您的标头行缺少SOAP 1.1 SOAPAction标头:
curl_setopt($soapme, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'SOAPAction: "Routing"', 'Content-Length: '.strlen($post_string) ));
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. 请注意,我将SOAPAction 路由称为SOAPAction 路由,但实际上,取决于Web服务和WSDL的定义,它实际上可以是任何东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.