url(r'soap/<str:user_id>/',
DjangoView.as_view(application=provider)),
在views.py 上
@ rpc(_returns=AnyDict)
def super_test_dict(self, one, two):
user_id = 1 #here need to receive the user_id
res = {"user_id":user_id}
return res
关于测试.py
self.soap_client = DjangoTestClient(
f'/soap/{org.str:user_id}/', provider)
res = self.soap_client.service.super_test_dict()
问题是,当我发送参数str:user_id不起作用,但如果没有发送任何正常的参数,我需要发送与请求相同的参数,但也需要在url上发送str:user_id。
super_test_dict方法的decorator没有反映您期望的输入参数。
我真的不确定你到底打算做什么,但要接收到你的web服务方法的输入,请更改你的视图.py以反映以下内容:
from spyne import Unicode, Integer
@ rpc(Unicode, Integer, _returns=AnyDict)
def super_test_dict(self, username, user_id):
print(f"Hello: {username}, your ID is: {user_id}")
res = {"user_id":user_id}
return res
还记得指定in_procol&out_procol在您的web服务应用程序">提供商"类中
你也可以从这里和这里获得更多的细节