Python中的Soap调用

Python中的Soap调用,python,soap,soappy,Python,Soap,Soappy,我试着打电话给soap服务。我的调用是成功的,但它返回空值。它将1d数组作为输入并返回该数组 请求模式 和我的输出 ***传出SOAP****************************************************** 1073757 1. 2. 99 ************************************************************************ ***来料肥皂*******************************

我试着打电话给soap服务。我的调用是成功的,但它返回空值。它将1d数组作为输入并返回该数组

请求模式

和我的输出

***传出SOAP******************************************************
1073757
1.
2.
99
************************************************************************
***来料肥皂******************************************************
************************************************************************
: {}

请帮我找到一个解决方案

这里有一个工作版本,它使用:

#/usr/bin/env python
从suds.xsd.doctor导入
从suds.client导入客户端
#启用日志记录以查看传输的XML
导入日志记录
logging.basicConfig(级别=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
#修复损坏的wsdl
#添加到wsdl
imp=导入('http://www.w3.org/2001/XMLSchema',
地点:http://www.w3.org/2001/XMLSchema.xsd')
imp.filter.add('http://tempuri.org/')
wsdl_url=http://204.9.76.243/nuCast.DataFeedService/Service1.asmx?WSDL'
client=client(wsdl\uurl,doctor=ImportDoctor(imp))
#请求
arrayofstring=client.factory.create('arrayofstring')
arrayofstring.string=[1,2]
打印client.service.CalculateWeb1D(1073757,arrayofstring,99).string
要求
DEBUG:suds.client:发送到(
http://204.9.76.243/nuCast.DataFeedService/Service1.asmx)
信息:
1073757
1.
2.
99
调试:suds.client:headers={
“SOAPAction”:u“http://tempuri.org/CalculateWeb1D"',
“内容类型”:“text/xml;charset=utf-8”}
回应
DEBUG:suds.client:http成功:
1.
2.
[1, 2]

解决方案是什么?具体问题是什么?对不起。在我的代码中,返回一个空集。实际上,web服务返回输入数组。我不知道为什么它会返回一个空集。谢谢,从一段时间以来到处寻找一个工作的SOAP客户端!
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <CalculateWeb1D xmlns="http://tempuri.org/">
      <HCID>string</HCID>
      <jaggedobjDataMICRO>
        <string>string</string>
        <string>string</string>
      </jaggedobjDataMICRO>
      <numeratorID>int</numeratorID>
    </CalculateWeb1D>
  </soap:Body>
</soap:Envelope>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <CalculateWeb1DResponse xmlns="http://tempuri.org/">
      <CalculateWeb1DResult>
        <string>string</string>
        <string>string</string>
      </CalculateWeb1DResult>
    </CalculateWeb1DResponse>
  </soap:Body>
</soap:Envelope>
from SOAPpy import WSDL

import warnings
warnings.simplefilter('ignore',DeprecationWarning)
import SOAPpy

wsdlFile = 'http://204.9.76.243/nuCast.DataFeedService/Service1.asmx?WSDL'
server = WSDL.Proxy(wsdlFile)
server.soapproxy.config.dumpSOAPOut = 1
server.soapproxy.config.dumpSOAPIn = 1
print server.CalculateWeb1D(str(1073757),[1,2],99)
*** Outgoing SOAP ******************************************************
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<SOAP-ENV:Body>
<CalculateWeb1D SOAP-ENC:root="1">
<v1 xsi:type="xsd:string">1073757</v1>
<v2 SOAP-ENC:arrayType="xsd:int[2]" xsi:type="SOAP-ENC:Array">
<item>1</item>
<item>2</item>
</v2>
<v3 xsi:type="xsd:int">99</v3>
</CalculateWeb1D>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************************************************************************
*** Incoming SOAP ******************************************************
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><CalculateWeb1DResponse xmlns="http://tempuri.org/" /></soap:Body></soap:Envelope>
************************************************************************
<SOAPpy.Types.structType CalculateWeb1DResponse at 171814380>: {}
#!/usr/bin/env python
from suds.xsd.doctor import Import, ImportDoctor
from suds.client import Client

# enable logging to see transmitted XML
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)

# fix broken wsdl
# add <s:import namespace="http://www.w3.org/2001/XMLSchema"/> to the wsdl
imp = Import('http://www.w3.org/2001/XMLSchema',
             location='http://www.w3.org/2001/XMLSchema.xsd')
imp.filter.add('http://tempuri.org/')
wsdl_url = 'http://204.9.76.243/nuCast.DataFeedService/Service1.asmx?WSDL'
client = Client(wsdl_url, doctor=ImportDoctor(imp))

# make request
arrayofstring = client.factory.create('ArrayOfString')
arrayofstring.string = [1,2]
print client.service.CalculateWeb1D(1073757, arrayofstring, 99).string
DEBUG:suds.client:sending to (
   http://204.9.76.243/nuCast.DataFeedService/Service1.asmx)
message:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://tempuri.org/"
   xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:CalculateWeb1D>
         <ns0:HCID>1073757</ns0:HCID>
         <ns0:jaggedobjDataMICRO>
            <ns0:string>1</ns0:string>
            <ns0:string>2</ns0:string>
         </ns0:jaggedobjDataMICRO>
         <ns0:numeratorID>99</ns0:numeratorID>
      </ns0:CalculateWeb1D>
   </ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {
  'SOAPAction': u'"http://tempuri.org/CalculateWeb1D"',
  'Content-Type': 'text/xml; charset=utf-8'}
DEBUG:suds.client:http succeeded:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <CalculateWeb1DResponse xmlns="http://tempuri.org/">
      <CalculateWeb1DResult>
        <string>1</string>
        <string>2</string>
      </CalculateWeb1DResult>
    </CalculateWeb1DResponse>
  </soap:Body>
</soap:Envelope>
[1, 2]