首先我导入了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文件中有问题吗?
答案 0 :(得分:1)
登录返回的serverUrl是针对企业API的,但是您没有使用它,您不应该更改programmerclienthandler_client
存根的端点URL,它已经是正确的。