我正在尝试使用 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>
任何人都知道我做错了什么请求元素为空并且不包含我的参数?
提前致谢!