开发者

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:

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);


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:

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜