我在php中通过curl发送一个soap请求,我得到了这个回复:
客户端无法在没有有效操作参数的情况下处理请求。 请提供有效的肥皂活动。
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);
答案 0 :(得分:1)
如果无法看到SOAP Web服务所期望并由WSDL定义的实际消息和操作类型,那么我可以打赌你的Headers行缺少SOAP 1.1 SOAPAction头:
curl_setopt($soapme, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8', 'SOAPAction: "Routing"', 'Content-Length: '.strlen($post_string) ));
请注意,我调用了SOAPAction Routing ,但根据提到的内容,它可能是Web服务期望和WSDL定义的内容。