alongfish
Alongfish
2019-03-27 16:31

python3.7 suds用CA证书访问webservice(server端CFX框架)报错

  • python

1、错误:Python3.7 用suds库ca证书,访问webservice的客户端,报‘suds.client:http failed‘,Server raised fault: 'A required header representing a Message Addressing Property is not present'"
2、调用service的方法后就报错
client = Client(url,transport=mytransport) 正常
print(client)可以看到webservice列表
当调用client.service.QueryByOwnerAndDateRequest()时出错,调试信息如下:

D:\JetBrains\Project\jing\venv\Scripts\python.exe D:/JetBrains/Project/jing/testwebservice.py
DEBUG:suds.transport.http:opening (http://172.16.21.190:9160/ws/RealestateQuery?WSDL)
DEBUG:suds.client:sending to (http://172.16.21.190:9160/ws/RealestateQuery?WSDL)
message:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://shghtd.com/regquery/types" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:QueryByOwnerAndDateRequest>
         <ns0:cardType>110001</ns0:cardType>
         <ns0:cardNo>620102197106285338</ns0:cardNo>
         <ns0:ownerName></ns0:ownerName>
         <ns0:date>2019-03-25</ns0:date>
      </ns0:QueryByOwnerAndDateRequest>
   </ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': '"http://shghtd.com/ws/RealestateQuery/queryHouseByOwnerAndDate"'}
DEBUG:suds.transport.http:sending:
URL:http://172.16.21.190:9160/ws/RealestateQuery?WSDL
HEADERS: {'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': '"http://shghtd.com/ws/RealestateQuery/queryHouseByOwnerAndDate"', 'Content-type': 'text/xml; charset=utf-8', 'Soapaction': '"http://shghtd.com/ws/RealestateQuery/queryHouseByOwnerAndDate"'}
MESSAGE:
b'<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://shghtd.com/regquery/types" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><ns1:Body><ns0:QueryByOwnerAndDateRequest><ns0:cardType>110001</ns0:cardType><ns0:cardNo>620102197106285338</ns0:cardNo><ns0:ownerName></ns0:ownerName><ns0:date>2019-03-25</ns0:date></ns0:QueryByOwnerAndDateRequest></ns1:Body></SOAP-ENV:Envelope>'
ERROR:suds.client:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://shghtd.com/regquery/types" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <ns1:Body>
      <ns0:QueryByOwnerAndDateRequest>
         <ns0:cardType>110001</ns0:cardType>
         <ns0:cardNo>620102197106285338</ns0:cardNo>
         <ns0:ownerName></ns0:ownerName>
         <ns0:date>2019-03-25</ns0:date>
      </ns0:QueryByOwnerAndDateRequest>
   </ns1:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.client:http failed:
b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode xmlns:ns1="http://www.w3.org/2005/08/addressing">ns1:MessageAddressingHeaderRequired</faultcode><faultstring>A required header representing a Message Addressing Property is not present</faultstring></soap:Fault></soap:Body></soap:Envelope>'
Traceback (most recent call last):
  File "D:\JetBrains\Project\jing\venv\lib\site-packages\suds\transport\http.py", line 78, in send
    fp = self.u2open(u2request)
  File "D:/JetBrains/Project/jing/testwebservice.py", line 69, in u2open
    return url.open(u2request, timeout=tm)
  File "D:\Python\Python37\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "D:\Python\Python37\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "D:\Python\Python37\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "D:\Python\Python37\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "D:\Python\Python37\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\JetBrains\Project\jing\venv\lib\site-packages\suds\client.py", line 652, in send
    reply = transport.send(request)
  File "D:\JetBrains\Project\jing\venv\lib\site-packages\suds\transport\http.py", line 86, in send
    raise TransportError(e.msg, e.code, e.fp)
suds.transport.TransportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/JetBrains/Project/jing/testwebservice.py", line 119, in <module>
    result = mzjweb(cardtype=ctype, cardno=cno, rightdate='2019-03-25')
  File "D:/JetBrains/Project/jing/testwebservice.py", line 111, in mzjweb
    ws = websev.queryHouseByOwnerAndDate(cardType=cardtype, cardNo=cardno, ownerName='', date=rightdate)
  File "D:\JetBrains\Project\jing\venv\lib\site-packages\suds\client.py", line 559, in __call__
    return client.invoke(args, kwargs)
  File "D:\JetBrains\Project\jing\venv\lib\site-packages\suds\client.py", line 618, in invoke
    result = self.send(soapenv)
  File "D:\JetBrains\Project\jing\venv\lib\site-packages\suds\client.py", line 664, in send
    result = self.failed(binding, e)
  File "D:\JetBrains\Project\jing\venv\lib\site-packages\suds\client.py", line 720, in failed
    r, p = binding.get_fault(reply)
  File "D:\JetBrains\Project\jing\venv\lib\site-packages\suds\bindings\binding.py", line 267, in get_fault
    raise WebFault(p, faultroot)
suds.WebFault: b"Server raised fault: 'A required header representing a Message Addressing Property is not present'"

Process finished with exit code 1

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答