我正在发出SOAP请求,并成功返回您可以调用的函数列表。
我正在调用PurgeRequest方法并收到以下错误
异常:class 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);
}
答案 0 :(得分:2)
它对我有用,但我没有登录(当然)。我得到了正常的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()方法来发送自定义标头,例如here。