gpt4 book ai didi

python - 为什么我用 Suds 得到 "Exception: (404, u' Not Found')"

转载 作者:太空狗 更新时间:2023-10-30 02:34:45 24 4
gpt4 key购买 nike

我正在尝试使用 Suds 连接到 SugarCRM soap 服务(正确的术语是什么?):

from suds.client import Client

url = "http://localhost/sugarcrm/soap.php?wsdl"
client = Client(url)
session = client.service.login("usr", "pwd")

但是最后一行抛出异常:

ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns3="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.sugarcrm.com/sugarcrm" xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header/>
<ns2:Body>
<ns1:login>
<user_auth xsi:type="ns1:user_auth">usr</user_auth>
<application_name xsi:type="ns3:string">pwd</application_name>
</ns1:login>
</ns2:Body>
</SOAP-ENV:Envelope>
Traceback (most recent call last):
File "python.py", line 5, in <module>
session = client.service.login("usr", "pwd")
File "/usr/lib/pymodules/python2.6/suds/client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "/usr/lib/pymodules/python2.6/suds/client.py", line 602, in invoke
result = self.send(soapenv)
File "/usr/lib/pymodules/python2.6/suds/client.py", line 653, in send
result = self.failed(binding, e)
File "/usr/lib/pymodules/python2.6/suds/client.py", line 714, in failed
raise Exception((status, reason))
Exception: (404, u'Not Found')

最佳答案

尝试将参数 location=url 也传递给 Client 构造函数。有时 WSDL 中的位置元素与服务器上的 URI 不匹配。

client = Client(url, location=url)

关于python - 为什么我用 Suds 得到 "Exception: (404, u' Not Found')",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6499770/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com