Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中使用sud通过SOAP Web服务访问联邦数据_Python_Xml_Web Services_Soap_Suds - Fatal编程技术网

在Python中使用sud通过SOAP Web服务访问联邦数据

在Python中使用sud通过SOAP Web服务访问联邦数据,python,xml,web-services,soap,suds,Python,Xml,Web Services,Soap,Suds,我正在尝试访问瑞士联邦政府商业登记处的Web服务() 然而,他们的文档是如此复杂和怪异,以至于我不知道如何构建它工作的请求 我对RESTAPI相当熟悉,但SOAP对我来说是新事物 我使用SoapUI成功构建了一个工作请求: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:uid="http://www.uid.admin.ch/xmlns/uid-wse" xmlns:

我正在尝试访问瑞士联邦政府商业登记处的Web服务()

然而,他们的文档是如此复杂和怪异,以至于我不知道如何构建它工作的请求

我对RESTAPI相当熟悉,但SOAP对我来说是新事物

我使用SoapUI成功构建了一个工作请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"    xmlns:uid="http://www.uid.admin.ch/xmlns/uid-wse" xmlns:ns="http://www.ech.ch/xmlns/eCH-0108-f/3" xmlns:ns1="http://www.ech.ch/xmlns/eCH-0098-f/3" xmlns:ns2="http://www.ech.ch/xmlns/eCH-0097-f/2" xmlns:ns3="http://www.ech.ch/xmlns/eCH-0046-f/3" xmlns:ns4="http://www.ech.ch/xmlns/eCH-0044-f/4" xmlns:ns5="http://www.ech.ch/xmlns/eCH-0010-f/6" xmlns:ns6="http://www.ech.ch/xmlns/eCH-0007-f/6">
<soapenv:Header/>
  <soapenv:Body>
    <uid:Search>
      <uid:searchParameters>
        <ns:organisation>
          <ns1:organisationIdentification>
              <ns2:organisationName>Beekeeper</ns2:organisationName>
           </ns1:organisationIdentification>
        </ns:organisation>
     </uid:searchParameters>
  </uid:Search>
</soapenv:Body>
</soapenv:Envelope>
构建上述请求的方法是什么


如何创建对SOAP的嵌套请求?

您应该看看

当您建立了基于wsdl模式或xsd文件的Python绑定后,您可以执行下面的代码来发出请求。显示您的操作将是什么

从pyxb.utils.six.moves.urllib导入请求作为urllib_请求
将pyxb.bundles.wssplat.soap11作为soapenv导入
#从XML创建SOAP信封
myenv=soapenv.Envelope(soapenv.Body(myxmlreq))
#为HTTP请求创建URL、标头和正文
url=”http://www.test.com"
headers={'Content-Type':'text/xml;charset=UTF-8',
“接受编码”:“gzip,deflate”,
“SOAPAction”:“http://test.com/API/Action“,#请参阅文档以了解操作
“连接”:“关闭”}设置服务器接受的内容
body=myenv.toxml(“utf-8”)
#创建请求,将其发送并以XML形式接收响应
uri=urllib_request.request(url,data=body,headers=headers)
rxml=urllib_request.urlopen(uri).read()#这是响应XML
 request_data = client.factory.create('s1:CityWeatherRequest')
 request_data.City = "Stockholm"