クライアントを実装するために python/suds を使用していますelement ref=
が、wsdl で定義された特定のタイプのパラメーターに対して、送信された SOAP ヘッダーで間違った名前空間プレフィックスを取得します。
.wsdl は、データ型の .xsd ファイルを参照しています。以下を参照してください。問題は、関数GetRecordAttributes
と type の最初の引数にありgbt:recordReferences
ます。
ファイル: browse2.wsdl
<xsd:schema targetNamespace="http://www.grantadesign.com/10/10/Browse" xmlns="http://www.grantadesign.com/10/10/Browse" xmlns:gbt="http://www.grantadesign.com/10/10/GrantaBaseTypes" elementFormDefault="qualified" attributeFormDefault="qualified">
<xsd:import schemaLocation="grantabasetypes2.xsd" namespace="http://www.grantadesign.com/10/10/GrantaBaseTypes"/>
<xsd:element name="GetRecordAttributes">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="gbt:recordReferences">
</xsd:element>
参照ファイル: grantabasetypes2.xsd
<element name="recordReferences">
<complexType>
<sequence>
<element name="record" minOccurs="0" maxOccurs="unbounded" type="gbt:MIRecordReference"/>
</sequence>
</complexType>
</element>
suds が送信する SOAP リクエスト:
<SOAP-ENV:Envelope xmlns:ns0="http://www.grantadesign.com/10/10/GrantaBaseTypes" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://www.grantadesign.com/10/10/Browse" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns2:GetRecordAttributes>
<ns2:recordReferences>
<ns0:record>
</ns0:record>
</ns2:recordReferences>
</ns2:GetRecordAttributes>
</ns1:Body>
</SOAP-ENV:Envelope>
問題: <ns2:recordReferences>
プレフィックスが間違っています 。これ は、.xsd で定義され <ns0:recordReferences>
た名前空間に属しているためです。...GrantaBaseTypes
ref=
これは、wsdl で定義されたすべての引数に対して発生します。これを自動的に修正するにはどうすればよいですか?
注: curl を介して xml SOAP リクエストを手動で送信することにより、「good」プレフィックスがサービスによって受け入れられることを確認しました。
アップデート
私は SUDS ソース コードをいじりました。次の経験的な修正により、ref=
属性を持つすべての要素が参照された名前空間を想定するように強制されます (以前は、スキーマ ルート名前空間などを使用していましたtns
)。
ファイル: /suds/xsd/sxbase.py
class SchemaObject(object):
....
def namespace(self, prefix=None):
ns = self.schema.tns
#FIX BEGIN
if self.ref and self.ref in self.schema.elements.keys():
ns = self.ref
#FIX END
私のサービスでは動作しますが、それが他のものを壊すかどうかはわかりません. SUDS のソース コードを変更しない、よりスマートなソリューションを希望します。
ありがとう、
アレックス