【发布时间】:2018-08-02 14:57:31
【问题描述】:
我必须使用 PHP 使用 SOAP Web 服务,但出现标题错误。
wsdl的(部分)结构是这样的:
<xs:element name="Obligations" type="tns:ObligationsType"/>
<xs:complexType name="ObligationsType">
<xs:sequence>
<xs:element maxOccurs="99" name="Taxes" type="tns:TaxesType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TaxesType">
<xs:sequence>
<xs:element name="tax">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:maxInclusive value="9999"/>
<xs:minInclusive value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="amount">
<xs:simpleType>
<xs:restriction base="xs:double">
<xs:minInclusive value="0.01"/>
<xs:maxInclusive value="9999999999.99"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
我发送的关联数组:
$params = array(
'token' => $TOKEN,
'sign' => $SIGN,
'paymentEntity' => 1001,
'form' => array(
'formNumber' => 6042,
'idPaymentType' => 951,
'Obligations' => array (
array(
'Taxes' => array(
'tax' => 6041,
'amount' => 602.0
)
)
)
)
);
我试图用类来做这件事,但我得到了同样的错误。问题出在 Obligations 对象上。
我试过这样嵌套:
'Obligations' =>array ('Taxes' =>array('tax'=> 1,'amount'=> 1.0)) 我得到 Unrecognized field Obligations
'Obligations' =>array ('tax'=> 1,'amount'=> 1.0) 我得到对象没有 'Taxes' 属性
'Obligations' =>array (array('Taxes' =>array('tax'=> 1,'amount'=> 1.0))) 我得到对象没有'tax'属性
'Obligations' =>array ('Taxes' =>array('tax'=> 1)) 我得到对象没有 'amount' 属性
'Obligations' =>array ('Taxes' =>array('amount'=> 1)) 我得到对象没有 'tax' 属性
最后一个请求 xml
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="...">
<SOAP-ENV:Body>
<ns1:createForm>
<ns1:token>********</ns1:token>
<ns1:sign>********</ns1:sign>
<ns1:paymentEntity>1001</ns1:paymentEntity>
<ns1:form>
<ns1:formNumber>6042</ns1:formNumber>
<ns1:idPaymentType>951</ns1:idPaymentType>
<ns1:Obligations>
<ns1:Taxes>
<tax>6041</tax>
<amount>602.0</amount>
</ns1:Taxes>
</ns1:Obligations>
</ns1:form>
</ns1:createForm>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
结构
"createFormResponse createForm(createForm $parameters)" [2]=> string(74)
"struct createForm { string token; string sign; int paymentEntity; FormType form; }"
"struct FormType { formNumber formNumber; idPaymentType idPaymentType; Obligations ObligationsType; }"
"struct ObligationsType { TaxesType Taxes; }"
"struct TaxesType { tax tax; amount amount; }"
我有一个请求示例,它与我获得的相同。 它只有一个注释
税收。该属性为列表类型。
税额。该属性为列表类型。
但它是已经在 wsdl 中标记的东西。
如果有任何建议,我将不胜感激。问候
【问题讨论】: