PHP Akamai SOAP Exception


PHP Akamai SOAP Exception

我正在发出一个SOAP请求,它成功地返回了您可以调用的函数列表。

我正在调用PurgeRequest方法,并收到以下错误

异常:class com.idox.soap.DemarshallException:在架构中键入与SOAP消息中的类型不同-应为string@httphttp://www.w3.org/1999/XMLSchema;得到Map@http://xml.apache.org/xml-soap"

我尝试了SOAP UI并获得了成功的响应id。但是,我的PHP请求失败了。。有人能告诉我这个错误是关于什么以及如何解决这个问题吗。一个引用说这是因为传递了空数组,但我确信该参数不是空的。

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

它对我有效,但我没有登录(当然)。我得到正常的SOAP异常:

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

当我在$opt或中传递一个空字符串时

  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和$url中传递空数组时。

无论如何,您的问题似乎是由于不同的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

并且SOAP扩展中的__doRequest()方法不会被覆盖以发送自定义头,就像这里一样。