首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WSDL中缺少WSDL:服务定义

WSDL中缺少WSDL:服务定义
EN

Stack Overflow用户
提问于 2017-09-11 19:49:45
回答 1查看 2K关注 0票数 0

我正在尝试使用ZEEP来处理SOAP请求。

我收到了这样的请求:

代码语言:javascript
复制
def status(request, IP):
    URL = "http://" + IP + "/Service"
    session = Session()
    session.auth = HTTPBasicAuth('username', 'password')
    client = Client(URL,
                    transport=Transport(session=session), strict=False)

    response = client.service.Method1(request={'getList'})

    return response

但是我遇到了在WSDL中缺少wsdl:service定义的错误。

我被卡住了,找不到更多的方法来查找故障。有什么想法吗?

编辑上下文。这是一个可以工作的硬编码请求,我正在尝试使用zeep:

代码语言:javascript
复制
 def GetList(session, IP):        

        request = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">'
        request = request + '<soapenv:Header>'
        request = request + '<session>' + session + '</session>'
        request = request + ' </soapenv:Header>'
        request = request + ' <soapenv:Body>'
        request = request + '<getList/>'
        request = request + '</soapenv:Body>'
        request = request + '</soapenv:Envelope>'

        request = u"""""" + request + """""".format()

        encoded_request = request.encode('utf-8')

        headers = {"Host": ""+ IP +"",
                   "Content-Type": "text/xml; charset=UTF-8",
                   "Content-Length": str(len(encoded_request)),
                   "SOAPAction": ""}

        response = requests.post(url="http://"+ url +"/Service",
                                 headers=headers,
                                 data=encoded_request,
                                 verify=False)

        return response.content

编辑2.添加wsdl

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>    
-<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:intf="http://xml.apache.org/axis/wsdd/ " xmlns:impl="http://xml.apache.org/axis/wsdd/ " xmlns:apachesoap="http://xml.apache.org/xml-soap" targetNamespace="http://xml.apache.org/axis/wsdd/ ">    
-<wsdl:types>    
-<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xml.apache.org/axis/wsdd/ ">    
<element type="xsd:anyType" name="parseMessage"/>    
<element type="xsd:anyType" name="parseMessageReturn"/>    
</schema>    
</wsdl:types>    
-<message name="parseMessageResponse">    
<part name="parseMessageReturn" element="impl:parseMessageReturn"/>    
</message>    
-<message name="parseMessageRequest">    
<part name="part" element="impl:parseMessage"/>    
</message>    
-<portType name="MessageHandlerProxy">    
-<operation name="parseMessage">    
<input name="parseMessageRequest" message="impl:parseMessageRequest"/>    
<output name="parseMessageResponse" message="impl:parseMessageResponse"/>    
</operation>    
</portType>    
-<binding type="impl:HandlerProxy" name="ServiceBinding">    
<wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>    
-<operation name="parseMessage">    
<wsdlsoap:operation soapAction=""/>    
-<input name="parseMessageRequest">    
<wsdlsoap:body use="literal" namespace="http://xml.apache.org/axis/wsdd/ "/>    
</input>    
-<output name="parseMessageResponse">    
<wsdlsoap:body use="literal" namespace="http://xml.apache.org/axis/wsdd/ "/>    
</output>    
</operation>    
</binding>    
-<service name="ProxyService">    
-<port name="Service" binding="impl:ServiceBinding">    
<wsdlsoap:address location="http://ip.ip.ip.ip/Service"/>    
</port>    
</service>    
</definitions>
EN

回答 1

Stack Overflow用户

发布于 2017-09-12 21:01:19

您必须在URL变量的末尾添加?wsdl

此外,您拨打电话的方式也不正确。对getList的调用应如下所示:

代码语言:javascript
复制
def status(request, IP):
    URL = "http://" + IP + "/Service?wsdl"
    session = Session()
    session.auth = HTTPBasicAuth('username', 'password')
    client = Client(URL,
                    transport=Transport(session=session), strict=False)

    response = client.service.getList([add the arguments here])

    return response
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46155065

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档