使用Spyne django python解析soap请求有问题吗?

时间:2018-11-01 10:25:58

标签: python django soap suds spyne

我正在学习在Django中构建一个Soap服务器和Soap客户端。通过Google,发现Spyne是用于构建Soap API的出色库,因此我尝试了它。一切正常。现在,我想在我的客户端服务器请求中添加标头身份验证,由于某种原因,我一直收到此烦人的错误。我可能做错了什么?

 raise Exception("message'%s', not-found" % mn)
Exception: message's0:headers', not-found

肥皂服务器

class Requestheader(ComplexModel):
    username = Unicode
    password = Unicode
class SoapService(ServiceBase):
    __in_header__ = Requestheader

    @rpc(Unicode(nillable=False), _returns=Unicode)
    def hello(ctx, name):
        username = ctx.in_header.username
        password = ctx.in_header.password
        print('username',username,password)
    return name

肥皂客户端

from suds.client import Client
from suds.cache import NoCache

my_client = Client('http://127.0.0.1:8000/demo/soap_service/?WSDL',cache=NoCache())
username ='rj'
password ='m12345'
my_client.set_options(headers=(username , password))
print ('Function hello: ', my_client.service.hello('BLUE'))

0 个答案:

没有答案