如何解决 SUDS 中没有可供请求的操作?
首先,我导入了 SUDS 客户端并进行日志记录,
from suds.client import Client as SudsClient
import logger
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
并向我提供了两个 wsdl 文件,即 enterprise.wsdl 和 ProgrammerClientHandler.wsdl.xml。 我使用 enterprise.wsdl 登录:
# Authentication and get more information for set up
enterprise_client = SudsClient(enterprise_url)
response = enterprise_client.service.login(username, "%s%s" % (password,token))
然后我将获取 sessionId 和 serverUrl 以传输到另一个 SUDS 客户端对象,
session_id = response.sessionId
server_url = response.serverUrl
soap_header = enterprise_client.factory.create('SessionHeader')
soap_header.sessionId = session_id
给出的 server_url 将 SUDS 客户端定向到用户,
programmerclienthandler_client = SudsClient(handler_url)
programmerclienthandler_client.set_options(soapheaders=[soap_header])
programmerclienthandler_client.set_options(location=server_url)
programmerclienthandler_client.set_options(port = 'ProgrammerClientHandler')
然后我通过打印programmerclienthandler_client 时
Service ( ProgrammerClientHandlerService ) tns="http://soap.sforce.com/schemas/class/axlea/ProgrammerClientHandler"
Prefixes (1)
ns0 = "http://soap.sforce.com/schemas/class/axlea/ProgrammerClientHandler"
Ports (1):
(ProgrammerClientHandler)
Methods (1):
getProgrammerClientXML()
Types (5):
ID
LogCategory
LogCategoryLevel
LogInfo
LogType
它显示了我现在需要的通过以下方式调用 getProgrammerClientXML() 函数:
programmerclienthandler_xml = programmerclienthandler_client.service.getProgrammerClientXML()
现在,当我调用此函数时,我收到错误:
DEBUG:suds.client:http failed:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>No operation available for request {http://soap.sforce.com/schemas/class/axlea/ProgrammerClientHandler}getProgrammerClientXML</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>
Error: ERROR: Server raised fault: 'No operation available for request {http://soap.sforce.com/schemas/class/axlea/ProgrammerClientHandler}getProgrammerClientXML'
我应该做什么才能使其工作? wsdl 文件有问题吗?
first I imported SUDS client and logging
from suds.client import Client as SudsClient
import logger
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
I was provided with two wsdl files, an enterprise.wsdl and ProgrammerClientHandler.wsdl.xml.
i used enterprise.wsdl to login by:
# Authentication and get more information for set up
enterprise_client = SudsClient(enterprise_url)
response = enterprise_client.service.login(username, "%s%s" % (password,token))
then i'll get the sessionId and serverUrl to transfer to another SUDS client object
session_id = response.sessionId
server_url = response.serverUrl
soap_header = enterprise_client.factory.create('SessionHeader')
soap_header.sessionId = session_id
then i direct the SUDS client to the user by the server_url that was given
programmerclienthandler_client = SudsClient(handler_url)
programmerclienthandler_client.set_options(soapheaders=[soap_header])
programmerclienthandler_client.set_options(location=server_url)
programmerclienthandler_client.set_options(port = 'ProgrammerClientHandler')
if I print programmerclienthandler_client it shows this
Service ( ProgrammerClientHandlerService ) tns="http://soap.sforce.com/schemas/class/axlea/ProgrammerClientHandler"
Prefixes (1)
ns0 = "http://soap.sforce.com/schemas/class/axlea/ProgrammerClientHandler"
Ports (1):
(ProgrammerClientHandler)
Methods (1):
getProgrammerClientXML()
Types (5):
ID
LogCategory
LogCategoryLevel
LogInfo
LogType
now i need to call the getProgrammerClientXML() function by:
programmerclienthandler_xml = programmerclienthandler_client.service.getProgrammerClientXML()
now when I call this I get the error:
DEBUG:suds.client:http failed:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Client</faultcode><faultstring>No operation available for request {http://soap.sforce.com/schemas/class/axlea/ProgrammerClientHandler}getProgrammerClientXML</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>
Error: ERROR: Server raised fault: 'No operation available for request {http://soap.sforce.com/schemas/class/axlea/ProgrammerClientHandler}getProgrammerClientXML'
What should I do to make it work? Is there a problem in the wsdl files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
登录返回的 serverUrl 用于企业 API,但您没有使用它,您不应该更改
programmerclienthandler_client
存根的端点 URL,它已经正确了。The serverUrl returned by login is for the enterprise API, but you're not using that, you shouldn't change the endpoint URL of your
programmerclienthandler_client
stub, its already correct.