我正在向(內部)soap服務發送請求。我目前正在測試SUDS(Jurko's fork)和OSA python soap庫。兩人都無法整理迴應。此SOAP響應是否與WSDL/XSD一致?
原始XML響應成功的請求是:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:geocodeAddressResponse xmlns:ns2="http://geocodegateway">
<geocodedAddress>
<streetLine>1 SOME STREET</streetLine>
<suburb>SOMEBURB</suburb>
<state>SS</state>
<postcode>1234</postcode>
<x>111.222222</x>
<y>-22.333333</y>
</geocodedAddress>
etc...
無論是OSA和SUDS庫引發異常:
- 的OSA的例外是
ValueError: 'streetLine' is not in list
。 - 肥皂水例外是
TypeNotFound: Type not found: 'streetLine'
的XSD SOAP服務(由WSDL導入)是:
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.7-b01-. --><xs:schema xmlns:gns="http://geocodegateway" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://geocodegateway">
<xs:element name="address" nillable="true" type="gns:address"></xs:element>
<xs:element name="geocodeAddressRequest" nillable="true" type="gns:geocodeAddressRequest"></xs:element>
<xs:element name="geocodeAddressResponse" nillable="true" type="gns:geocodeAddressResponse"></xs:element>
<xs:complexType name="address">
<xs:sequence>
<xs:element name="streetLine" type="xs:string"></xs:element>
<xs:element name="suburb" type="xs:string"></xs:element>
<xs:element name="state" type="xs:string"></xs:element>
<xs:element name="postcode" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="geocodeAddressRequest">
<xs:sequence>
<xs:element name="appId" type="xs:string"></xs:element>
<xs:element name="address" nillable="true" type="gns:address"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="geocodeAddressResponse">
<xs:sequence>
<xs:element name="responseCode" type="xs:string" maxOccurs="1" minOccurs="1"></xs:element>
<xs:element name="geocodedAddress">
<xs:complexType>
<xs:sequence>
<xs:element name="address" nillable="true" type="gns:address"></xs:element>
<xs:element name="x" type="xs:string"></xs:element>
<xs:element name="y" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
如果我經由SUDS MessagePlugin鉤包裹streetLine修改響應XML ,郊區等等......地址元素中的元素,則SUDS會正確編組響應。或者,如果我使用泡沫DocumentPlugin鉤子(如下所示)來修改XSD以刪除地址類型幷包括單獨的街道線,郊區等...元素,則SUDS會正確地編組響應。
<xs:complexType name="geocodeAddressResponse">
<xs:sequence>
<xs:element name="responseCode" type="xs:string" maxOccurs="1" minOccurs="1"/>
<xs:element name="geocodedAddress">
<xs:complexType>
<xs:sequence>
<xs:element name="streetLine" type="xs:string"></xs:element>
<xs:element name="suburb" type="xs:string"></xs:element>
<xs:element name="state" type="xs:string"></xs:element>
<xs:element name="postcode" type="xs:string"></xs:element>
<xs:element name="x" type="xs:string"></xs:element>
<xs:element name="y" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
我建議SOAP服務的開發者,也許XSD或XML響應應當被修改以便它們是一致的,但被告知,他們似乎是正確的,並檢查了Python SOAP庫我使用是指定/解釋文檔/文字與文檔/文字正確包裝(我不知道這是如何適用於此)。
問題:SOAP響應是否與WSDL/XSD一致,並且python soap庫沒有正確解釋它(或者我沒有正確使用它們)?