如何解决此 SOAP 异常 'Unmarshalling Error'
How do I solve this SOAP exception 'Unmarshalling Error'
我正在从事一个项目,我在其中使用内部托管的第 3 方应用程序的 SOAP API(BMC FootPrints 服务核心)。我可以使用 PHP 调用 API,我的凭据很好,在一个特定的 API 方法中,我正在对 API 进行看起来有效的调用=33=] 函数,但出现以下异常/错误:
SoapFault exception: [soap:Client] Unmarshalling Error: cvc-complex-type.2.4.b: The content of element 'ns1:runSearch' is not complete. One of '{runSearchRequest}' is expected
“预期‘{runSearchRequest}’之一”部分的确切含义是什么?我不明白我向 API 发出的请求还需要包含什么。
可以在此处找到 API 文档,具体来说,第 31 页指的是我尝试使用的 API 方法,记录在此处的屏幕截图中:image from PDF.
我不会 post 所有代码,但只是我尝试 API 方法的部分:
// array that will be used in the method call...
$searchFor = array(
"_searchId"=>"11",
);
try {
$response = $soapClient->__soapCall("runSearch", $searchFor);
print_r($response);
} catch (SoapFault $exception) {
echo $exception;
}
我用 SOAPUI 应用程序测试了方法调用,我能够很好地看到结果/响应。
更新:添加 WSDL xml(片段)...
我正在使用 WSDL,但它托管在我们的内部/本地网络上,没有暴露在外部,这是 XML 的开始和来自该 WSDL 的 runSearch 类型:
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://externalapi.business.footprints.numarasoftware.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="ExternalApiService" targetNamespace="http://externalapi.business.footprints.numarasoftware.com/">
<wsdl:types>
<schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xxxxxxxxxxxxxxxxxxxx.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="xxxxxxxxxxxxxxxxxxxxxxxx" schemaLocation="http://xxxxxxxxxxxxxxxxxxxxxxxx:PORT/footprints/servicedesk/externalapisoap/ExternalApiServicePort?xsd=externalapiservices_schema.xsd"/>
</schema>
</wsdl:types>
...
<wsdl:message name="runSearch">
<wsdl:part element="tns:runSearch" name="parameters">
</wsdl:part>
</wsdl:message>
错误表明您的 runSearchReqeust
结构(即您的 $searchFor
)缺少信息。您提供的文档表明 runSearch()
调用的签名如下所示:
runSearchResponse runSearch(runSearch $runSearch)
此外,runSearch
数据类型将包含一个 RunSearchRequest
类型的字段。
所以你需要一个包含元素 'runSearchRequest'
的数据结构,它本身是另一个包含 _searchId
的数据结构
尝试:
$searchFor = array(
'runSearchRequest' => array(
"_searchId" => "11",
)
);
并将您的呼叫更改为:
$response = $soapClient->runSearch($searchFor);
或者:
$response = $soapClient->__soapCall("runSearch", array($searchFor));
这将生成一个 SOAP XML 请求,与文档中的请求非常匹配:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://externalapi.business.footprints.numarasoftware.com/">
<SOAP-ENV:Body>
<ns1:runSearch>
<runSearchRequest>
<_searchId>11</_searchId>
</runSearchRequest>
</ns1:runSearch>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
解组错误的发生有两个原因:
Exception: Unmarshalling Error: null
:如果键后有空格
Exception: Unmarshalling Error: For input string: "233,43"
:因为Amount必须是233.43
我正在从事一个项目,我在其中使用内部托管的第 3 方应用程序的 SOAP API(BMC FootPrints 服务核心)。我可以使用 PHP 调用 API,我的凭据很好,在一个特定的 API 方法中,我正在对 API 进行看起来有效的调用=33=] 函数,但出现以下异常/错误:
SoapFault exception: [soap:Client] Unmarshalling Error: cvc-complex-type.2.4.b: The content of element 'ns1:runSearch' is not complete. One of '{runSearchRequest}' is expected
“预期‘{runSearchRequest}’之一”部分的确切含义是什么?我不明白我向 API 发出的请求还需要包含什么。
可以在此处找到 API 文档,具体来说,第 31 页指的是我尝试使用的 API 方法,记录在此处的屏幕截图中:image from PDF.
我不会 post 所有代码,但只是我尝试 API 方法的部分:
// array that will be used in the method call...
$searchFor = array(
"_searchId"=>"11",
);
try {
$response = $soapClient->__soapCall("runSearch", $searchFor);
print_r($response);
} catch (SoapFault $exception) {
echo $exception;
}
我用 SOAPUI 应用程序测试了方法调用,我能够很好地看到结果/响应。
更新:添加 WSDL xml(片段)...
我正在使用 WSDL,但它托管在我们的内部/本地网络上,没有暴露在外部,这是 XML 的开始和来自该 WSDL 的 runSearch 类型:
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://externalapi.business.footprints.numarasoftware.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="ExternalApiService" targetNamespace="http://externalapi.business.footprints.numarasoftware.com/">
<wsdl:types>
<schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xxxxxxxxxxxxxxxxxxxx.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="xxxxxxxxxxxxxxxxxxxxxxxx" schemaLocation="http://xxxxxxxxxxxxxxxxxxxxxxxx:PORT/footprints/servicedesk/externalapisoap/ExternalApiServicePort?xsd=externalapiservices_schema.xsd"/>
</schema>
</wsdl:types>
...
<wsdl:message name="runSearch">
<wsdl:part element="tns:runSearch" name="parameters">
</wsdl:part>
</wsdl:message>
错误表明您的 runSearchReqeust
结构(即您的 $searchFor
)缺少信息。您提供的文档表明 runSearch()
调用的签名如下所示:
runSearchResponse runSearch(runSearch $runSearch)
此外,runSearch
数据类型将包含一个 RunSearchRequest
类型的字段。
所以你需要一个包含元素 'runSearchRequest'
的数据结构,它本身是另一个包含 _searchId
尝试:
$searchFor = array(
'runSearchRequest' => array(
"_searchId" => "11",
)
);
并将您的呼叫更改为:
$response = $soapClient->runSearch($searchFor);
或者:
$response = $soapClient->__soapCall("runSearch", array($searchFor));
这将生成一个 SOAP XML 请求,与文档中的请求非常匹配:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://externalapi.business.footprints.numarasoftware.com/">
<SOAP-ENV:Body>
<ns1:runSearch>
<runSearchRequest>
<_searchId>11</_searchId>
</runSearchRequest>
</ns1:runSearch>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
解组错误的发生有两个原因:
Exception: Unmarshalling Error: null
:如果键后有空格Exception: Unmarshalling Error: For input string: "233,43"
:因为Amount必须是233.43