2012-01-23 51 views
0

我正在發出一個SOAP請求,並且它成功返回了可以調用的函數列表。PHP Akamai SOAP異常

我打電話PurgeRequest方法和接收以下錯誤

異常:類com.idoox.soap.DemarshallException:在模式 類型從在SOAP消息類型的不同 - 預期 串@ HTTP:// WWW .w3.org/1999/XMLSchema的;有 地圖@ HTTP://xml.apache.org/xml-soap」

我試着用SOAP UI,並獲得成功的響應ID,但是,我的PHP請求failing..Can一些人告訴我。這是什麼錯誤是關於如何解決這個問題。一個參考說,這是因爲經過空數組,但我相信,參數不爲空。

if(class_exists('SoapClient')) 
{ 
    $client = new SoapClient('https://ccuapi.akamai.com/ccuapi.wsdl', 
        array(
        'trace' => 1, 
        'exceptions' => 0, 
        'features' => SOAP_USE_XSI_ARRAY_TYPE 
        ) 
    ); 
    echo '<pre>'; 
    var_dump($client->__getFunctions()); 
    try { 

     $purgeResult = $client->purgeRequest($username,$password,'',$opt,$url); 
    } 
    catch(SoapFault $e){ 
     echo "Exception\n"; 
    } 
    echo '<pre>'; 
    var_dump($purgeResult); 
} 

回答

1

它爲我,但我不記錄(當然)我得到正常的SOAP例外:

Exception: class com.idoox.soap.DemarshallException: Dimensions not found in array type 

當我通過在$選擇一個空字符串,或

object(stdClass)#2 (6) { 
    ["resultCode"]=> 
    int(301) 
    ["resultMsg"]=> 
    string(29) "Invalid username or password." 
    ["sessionID"]=> 
    string(16) "17F1327329982356" 
    ["estTime"]=> 
    int(-1) 
    ["uriIndex"]=> 
    int(-1) 
    ["modifiers"]=> 
    NULL 
} 
當我通過在$ opt和$網址空數組

無論如何,你的問題似乎是由於不同的SOAP xsd頭。服務期望http://www.w3.org/1999/XMLSchema標題,您的腳本似乎通過http://xml.apache.org/xml-soap

服務WSDL定義它:

<?xml version="1.0" standalone="no"?> 
<definitions name="PurgeRequest" 
    targetNamespace="http://www.akamai.com/purge" 
    xmlns:tns="http://www.akamai.com/purge" 
    xmlns:purgedt="http://www.akamai.com/purge" 
    xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns="http://schemas.xmlsoap.org/wsdl/"> 

你需要確保你的客戶尊重這一點,並設置正確。

請發表您的

var_dump($client->__getLastRequest()); 

(後右

var_dump($purgeResult); 

) 礦的輸出是這樣的:

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns1="http://www.akamai.com/purge" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
    <SOAP-ENV:Body> 
    <ns1:purgeRequest> 
     <name xsi:type="xsd:string">ee</name> 
     <pwd xsi:type="xsd:string">rr</pwd> 
     <network xsi:type="xsd:string"/> 
     <opt SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array"> 
     <item xsi:type="xsd:string"/> 
     </opt> 
     <uri SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array"> 
     <item xsi:type="xsd:string"/> 
     </uri> 
    </ns1:purgeRequest> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

看到,這個請求功能的xmlns:XSD =「http://www.w3.org/2001/XMLSchema 「

還要確保您使用正確的SOAP版本

'soap_version' => SOAP_1_1 

和你__doRequest()的SOAP擴展方法是沒有覆蓋到發送自定義標題,如:here

+0

我想在你的迴應是字符串,而在我的是<選擇XSI:類型= 「NS2:地圖」> <關鍵的xsi:type = 「XSD:字符串」>電子郵件通知<值XSI: type =「xsd:string」> [email protected] ....任何想法如何糾正? – user269867

+0

您能否使用var_dump($ client - > __ getLastRequest())的輸出更新帖子; ? – Snifff