我试图从荷兰政府土地登记处(WSDL here)和PySimpleSoap)的SOAP服务获取相关信息。到目前为止,我成功地使用以下代码连接并请求有关特定属性的信息:
from pysimplesoap.client import SoapClient
client = SoapClient(wsdl='http://www1.kadaster.nl/1/schemas/kik-inzage/20141101/verzoekTotInformatie-2.1.wsdl', username='xxx', password='xxx', trace=True)
response = client.VerzoekTotInformatie(
Aanvraag={
'berichtversie': '4.7', # Refers to the schema version
'klantReferentie': klantReferentie, # A reference we can set ourselves.
'productAanduiding': '1185', # a four-digit code referring to whether the response should be in "XML" (1185), "PDF" (1191) or "XML and PDF" (1057).
'Ingang': {
'Object': {
'IMKAD_KadastraleAanduiding': {
'gemeente': 'ARNHEM AC', # municipality
'sectie': 'AC', # section code
'perceelnummer': '1234' # Lot number
}
}
}
}
)
这个“有点”行得通。我设置了trace=True
,因此我得到了大量的日志消息,在这些日志消息中,我看到了一个庞大的xml输出(paste here),它几乎包括了我请求的所有信息。但是,我也得到了回溯:
据我所知,这意味着IMKAD_Perceel
标记不能被{a4}理解,这是因为它无法在wdsl文件中读取/找到该标记的定义。在
因此,我检查了解析wsdl文件的(大量)日志消息,其中显示了以下几行:
DEBUG:pysimplesoap.helpers:Parsing Element element: IMKAD_Perceel
DEBUG:pysimplesoap.helpers:Processing element IMKAD_Perceel element
DEBUG:pysimplesoap.helpers:IMKAD_Perceel has no children!
DEBUG:pysimplesoap.helpers:complexContent/simpleType/element IMKAD_Perceel = IMKAD_Perceel
DEBUG:pysimplesoap.helpers:Parsing Element complexType: IMKAD_Perceel
DEBUG:pysimplesoap.helpers:Processing element IMKAD_Perceel complexType
DEBUG:pysimplesoap.helpers:complexContent/simpleType/element IMKAD_Perceel = IMKAD_OnroerendeZaak
DEBUG:pysimplesoap.helpers:Processing element IMKAD_Perceel complexType
我想这几行意味着IMKAD_Perceel
定义是空的。所以我用SoapUI来反省the WSDL file,在其中我找到了IMKAD_Perceel
的定义{a7}:
<xs:element name="IMKAD_Perceel"
substitutionGroup="ipkbo:IMKAD_OnroerendeZaak"
type="ipkbo:IMKAD_Perceel"
/>
标签看起来确实在关闭,这意味着它是空的。这就是pysimplesoap认为未定义IMKAD_Perceel
的原因吗?为什么它不能简单地解释xml并将其作为dict返回呢?(如前所述,我收到的完整xml输出在this paste中)。在
有人知道我如何让pysimplesoap解释xml并将其转换为dict,而不管它是否符合wsdl?在
欢迎所有提示!在
似乎
pysimplesoap
不能处理xmlschema中的substitutionGroup
。在在xsd文件中可以看到:
^{1}$这里有一个}是同一个东西,可以互相替代。在
substitutionGroup
,这意味着IMKAD_Perceel
和{在soap模式中,响应的这一特定部分定义为:
^{pr2}$但是,您可以看到实际的响应是:
那么
pysimplesoap
似乎很困惑,无法得到正确的响应类型。在相关问题 更多 >
编程相关推荐