PHP Akamai SOAP 异常

发布于 2024-12-28 09:21:29 字数 977 浏览 0 评论 0原文

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

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

异常:类 com.idoox.soap.DemarshallException:输入架构 与 SOAP 消息中的类型不同 - 预期 字符串@http://www.w3.org/1999/XMLSchema;得到 地图@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);
}

I am making a SOAP request and it successfully return the function list which you can call.

I am calling PurgeRequest method and receiving following error

Exception: class com.idoox.soap.DemarshallException: Type in schema
differs from type in SOAP message - expected
string@http://www.w3.org/1999/XMLSchema; got
Map@http://xml.apache.org/xml-soap"

I tried with SOAP UI and get the successful response id. But, my PHP request is failing..Can some one tell me what this error is about and how to resolve this. one reference say it is because of passing the empty array but I am sure that parameter is not empty.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

看透却不说透 2025-01-04 09:21:29

它对我有用,但我没有登录(当然)。我得到正常的 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() 方法未被覆盖发送自定义标头,例如 此处

It works for me, but I'm not logging in (of course). I get normal SOAP exceptions:

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

when I pass an empty string in $opt, or

  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
}

when I pass empty arrays in $opt and $url.

Anyway, your issue seems to be due to different SOAP xsd headers. The service expects http://www.w3.org/1999/XMLSchema header, your script seems to be passing http://xml.apache.org/xml-soap.

Service WSDL defines it:

<?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/">

You need to make sure your client respects this and sets it properly.

Please post output of your

var_dump($client->__getLastRequest());

(right after

var_dump($purgeResult);

)
mine looks like this:

<?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>

see, this request features xmlns:xsd="http://www.w3.org/2001/XMLSchema"

Also make sure you are using right SOAP version

'soap_version'   => SOAP_1_1

and your __doRequest() method in SOAP extension is not overriden to send custom headers, like here.

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