如何反思SOAP数据类型?

2024-09-30 08:32:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我以前从未使用过SOAP,现在我正试图跟随this tutorial来了解荷兰政府土地登记处的SOAP服务(卡达斯特.nl)公司名称:

>>> from SOAPpy import WSDL
>>> server = WSDL.Proxy('http://www1.kadaster.nl/1/schemas/kik-inzage/20141101/verzoekTotInformatie-2.1.wsdl')
/Library/Python/2.7/site-packages/wstools/XMLSchema.py:1280: UserWarning: annotation is ignored
  warnings.warn('annotation is ignored')
/Library/Python/2.7/site-packages/wstools/XMLSchema.py:1217: UserWarning: Not keeping schema component.
  warnings.warn("Not keeping schema component.")
>>> server.methods.keys()
[u'VerzoekTotInformatie']
>>> callInfo = server.methods['VerzoekTotInformatie']
>>> callInfo.inparams[0].name
u'body'
>>> callInfo.inparams[0].type
(u'http://www.kadaster.nl/schemas/kik-inzage/20141101', u'VerzoekTotInformatieRequest')

所以我现在明白了,我需要用VerzoekTotInformatieRequest类型的消息调用方法VerzoekTotInformatie(转换为RequestForInformation)。在

但从这里我有点迷路了。如何构造这样一个VerzoekTotInformatieRequest?我如何进一步反省这一点?在

如有任何关于如何从这里着手的建议,我们将不胜感激。在

如果我应该使用另一个库(但我更喜欢Python),那也没问题。我读到了关于suds的好消息,但是因为它没有提交for over 3 years,所以我认为它是放弃软件。我还尝试了pysimplesoap,它看起来不错,但我不知道如何使用它来反省SOAP服务。在


Tags: httpserverpackagesnllibrarysiteschemassoap
1条回答
网友
1楼 · 发布于 2024-09-30 08:32:46

你对这一点的看法是正确的。但是,我首先要使用SOAP客户机工具来研究WSDL,以了解它的结构和引用。当您查看WSDL时,请注意在名为verzoekTotInformatie-2.1.xsd的引用的.xsd模式中如何定义类型。然后,此架构引用并包含20个其他架构文件:

High-res image - click here.

enter image description here

显然,在您的情况下,仅仅通过自己阅读来跟踪所有事情会变成一场噩梦(无论如何,WSDL对于人类的阅读并不是有意的,但是您的WSDL是非常非常非常嵌套的)。在

因此,我建议您在SOAP UI(它是免费的,这是我在上面的屏幕截图中使用的)中导入这个WSDL,并使用WSDL url创建一个新项目:

http://www1.kadaster.nl/1/schemas/kik-inzage/20141101/verzoekTotInformatie-2.1.wsdl

它将导入所有内容并为您创建一个示例请求。对我来说,它甚至试图根据字段类型添加一些lorem ipsum示例数据:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.kadaster.nl/schemas/kik-inzage/20141101" xmlns:v20="http://www.kadaster.nl/schemas/kik-inzage/ip-aanvraag/v20141101">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:VerzoekTotInformatieRequest>
         <v20:Aanvraag>
            <v20:berichtversie>4.7</v20:berichtversie>
            <v20:klantReferentie>cum murmure</v20:klantReferentie>
            <v20:productAanduiding>aeoliam venit</v20:productAanduiding>
            <! Optional: >
            <v20:Gebruiker>
               <v20:identificatie>ventos tempestatesqu</v20:identificatie>
            </v20:Gebruiker>
            <v20:Ingang>
               <! You have a CHOICE of the next 3 items at this level >
               <v20:Object>
                  <! You have a CHOICE of the next 2 items at this level >
                  <v20:IMKAD_OZLocatie>
                     <v20:adres>
                        <v20:BAG_NummerAanduiding>
                           <v20:postcode>temper</v20:postcode>
                           <v20:huisnummer>turbine corripuit</v20:huisnummer>
                           <! Optional: >
                           <v20:huisletter>r</v20:huisletter>
                           <! Optional: >
                           <v20:huisnummertoevoeging>frem</v20:huisnummertoevoeging>
                        </v20:BAG_NummerAanduiding>
                     </v20:adres>
                     <! Optional: >
                     <v20:bijOfTegenover>ferant rapidi</v20:bijOfTegenover>
                  </v20:IMKAD_OZLocatie>
                  <v20:IMKAD_KadastraleAanduiding>
                     <! Optional: >
                     <v20:gemeente>sceptra tenens</v20:gemeente>
                     <v20:sectie>turbine corripuit scopuloque</v20:sectie>
                     <v20:perceelnummer>flamm</v20:perceelnummer>
                     <! Optional: >
                     <v20:appartementsindex>prof</v20:appartementsindex>
                     <! Optional: >
                     <v20:deelperceelnummer>nubi</v20:deelperceelnummer>
                     <! Optional: >
                     <v20:AKRKadastraleGemeenteCode>ac vi</v20:AKRKadastraleGemeenteCode>
                  </v20:IMKAD_KadastraleAanduiding>
               </v20:Object>
               <v20:PersoonsIngang>
                  <v20:Persoon>
                     <! You have a CHOICE of the next 4 items at this level >
                     <v20:BSN>100</v20:BSN>
                     <! Optional: >
                     <v20:KVKNummer>rapidum</v20:KVKNummer>
                     <! Optional: >
                     <v20:RSIN>caelumque</v20:RSIN>
                     <v20:kadastraleIdentificatie>100</v20:kadastraleIdentificatie>
                  </v20:Persoon>
                  <! Optional: >
                  <v20:Restrictie>
                     <v20:maximumAantalObjecten>100</v20:maximumAantalObjecten>
                  </v20:Restrictie>
               </v20:PersoonsIngang>
               <v20:Brondocument>
                  <v20:IMKAD_DeelEnNummer>
                     <v20:deel>circu</v20:deel>
                     <v20:nummer>coniu</v20:nummer>
                     <! Optional: >
                     <v20:reeks>arce sceptra</v20:reeks>
                     <v20:ipa_registerCodeSub>circum claustra fremunt</v20:ipa_registerCodeSub>
                  </v20:IMKAD_DeelEnNummer>
               </v20:Brondocument>
            </v20:Ingang>
         </v20:Aanvraag>
      </ns:VerzoekTotInformatieRequest>
   </soapenv:Body>
</soapenv:Envelope>

导入所有内容后,您可以展开项目,然后右键单击绑定VezorekToInformatieBinding,然后选择Show Interface Viewer来探索任何需要进一步反省的类型(包括请求),这些类型是在引用的架构中定义的。在

有了完整的定义,你就可以更容易地进行反省。在您的例子中,必须有一个选项来导入WSDL并首先“扩展”所有的include/reference,只有当您有完整的图片可用时,才可以开始自省。如果没有这样的选项,您可能必须遵循引用并逐个包含。在

希望这是一个起点。祝你好运!在

相关问题 更多 >

    热门问题