簡體   English   中英

php curl with soap error:沒有有效的動作參數就無法處理請求

[英]php curl with soap error: unable to handle request without valid action parameter

我通過curl在php中發送了一個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>';

卷曲:

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

在無法看到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) )); 

請注意,我將SOAPAction 路由稱為SOAPAction 路由,但實際上,取決於Web服務和WSDL的定義,它實際上可以是任何東西。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM