php 卷曲与肥皂错误:无法处理没有有效操作参数的请求

发布于 2024-11-26 13:32:56 字数 1622 浏览 1 评论 0原文

我通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆光飞翔i 2024-12-03 13:32:56

如果无法看到 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 路由,但它实际上可以是任何东西,具体取决于前面提到的 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:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文