[英]PHP Soap request tag empty
我正在嘗試使用php來調用ASP.net(我很確定這是服務器)。
我發送的請求有問題。 我相信這是wsdl的重要組成部分。 (請注意,我對SOAP缺乏經驗)。
<s:element name="GetAssetDetails">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="request" nillable="true" type="tns:AssetDetailsRequest"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="AssetDetailsRequest">
<s:complexContent mixed="false">
<s:extension base="tns:RequestBase">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="AssetGuid" nillable="true" type="s1:guid"/>
<s:element minOccurs="1" maxOccurs="1" name="AssetId" nillable="true" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" name="AssetName" type="s:string"/><s:element minOccurs="1" maxOccurs="1" name="RequestedInfos" nillable="true" type="tns:AssetInfos"/>
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
以下XML給出了正確的響應(作為測試我已覆蓋__doRequest並將其作為完整的xml請求)
$request = '<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetAssetDetails xmlns="http://xxxx/...">
<request>
<AssetName>arg1</AssetName>
<RequestedInfos>option1 option2</RequestedInfos>
</request>
</GetAssetDetails>
</soap12:Body>
</soap12:Envelope>';
所以我實際上不需要AssetGuid。 然而,似乎WSDL說我必須(但我不確定我是否正確解釋了這一點)。
現在我做了什么:
$ap_param = array(
// 'AssetGuid' => 'EUAUDYEHDOUIDFHADHSJLKW', // Tried with and without this, random value
'AssetName' => 'arg1',
'RequestedInfos' => 'option1 option2'
);
$info = $soapClient->__call("GetAssetDetails", array($ap_param));
但是,在通過網絡傳輸的XML中,請求標記為空:
<?xml version="1.0" encoding="UTF-8"?>
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://xxx/..."
<soap12:Body>
<GetAssetDetails>
<request xsi:nil="true"/>
</GetAssetDetails></soap12:Body>
</soap12:Envelope>
回應是:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<soap:Code><soap:Value>soap:Sender</soap:Value></soap:Code>
<soap:Reason><soap:Text xml:lang="en">Unable to handle request without a valid action parameter. Please supply a valid soap action.</soap:Text></soap:Reason>
<soap:Detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
任何人都知道我做錯了,請求元素是空的並且不保存我的參數?
提前致謝!
似乎不推薦使用 SoapClient :: _ call嘗試使用SoapClient :: _soapCall而不是它。 http://www.php.net/manual/en/soapclient.soapcall.php
我有同樣的問題。 悲哀的是,我的解決方案是與我的提供者交談,讓他們知道如果刪除該元素,我就無法遵守WSDL。
無論如何,我猜你總是可以在http://codeidol.com/community/php/calling-a-soap-method-without-wsdl/20070/上實現一些SOAP解決方案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.