【发布时间】:2017-10-13 08:33:07
【问题描述】:
我不得不向这个网络服务发出肥皂请求,但每次我得到一个错误 请求的配偶是这样的:
POST /NewIPGServices/Sale/SaleService.asmx HTTP/1.1
Host: pec.shaparak.ir
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://pec.Shaparak.ir/NewIPGServices/Sale/SaleService/SalePaymentRequest"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SalePaymentRequest xmlns="https://pec.Shaparak.ir/NewIPGServices/Sale/SaleService">
<requestData />
</SalePaymentRequest>
</soap:Body>
</soap:Envelope>
这是我的代码:
def ps_pymnt(request):
location ="https://pec.Shaparak.ir/NewIPGServices/Sale/SaleService"
PS_webService = "https://pec.shaparak.ir/NewIPGServices/Sale/SaleService.asmx"
client=Client(PS_webService,location=location) #from suds.client import Client
print(client)
.
.
.
return something
在代码到达打印行之前我有这个错误:
Request Method: GET
Request URL: http://127.0.0.1:8002/payment/ps/pay/
Traceback:
File "/home/salman/salman/Projects/vira04/virtual/lib/python3.5/site-
packages/django/core/handlers/base.py" in get_response
149. response =
self.process_exception_by_middleware(e, request)
File "/home/salman/salman/Projects/vira04/virtual/lib/python3.5/site-
packages/django/core/handlers/base.py" in get_response
147. response = wrapped_callback(request,
*callback_args, **callback_kwargs)
File "/home/salman/salman/Projects/vira05/vira-285-
parsianPayment/virasciencecom/payment/views.py" in ps_port_payment
298. client = Client(PS_webService, location=location)
File "/home/salman/salman/Projects/vira04/virtual/lib/python3.5/site-
packages/suds/client.py" in __init__
111. self.wsdl = reader.open(url)
File "/home/salman/salman/Projects/vira04/virtual/lib/python3.5/site-
packages/suds/reader.py" in open
151. d = self.fn(url, self.options)
File "/home/salman/salman/Projects/vira04/virtual/lib/python3.5/site-
packages/suds/wsdl.py" in __init__
135. d = reader.open(url)
File "/home/salman/salman/Projects/vira04/virtual/lib/python3.5/site-
packages/suds/reader.py" in open
78. d = self.download(url)
File "/home/salman/salman/Projects/vira04/virtual/lib/python3.5/site-
packages/suds/reader.py" in download
94. fp = self.options.transport.open(Request(url))
File "/home/salman/salman/Projects/vira04/virtual/lib/python3.5/site-
packages/suds/transport/http.py" in open
174. return HttpTransport.open(self, request)
File "/home/salman/salman/Projects/vira04/virtual/lib/python3.5/site-
packages/suds/transport/http.py" in open
63. return self.u2open(u2request)
File "/home/salman/salman/Projects/vira04/virtual/lib/python3.5/site-
packages/suds/transport/http.py" in u2open
119. return url.open(u2request, timeout=tm)
File "/usr/lib/python3.5/urllib/request.py" in open
466. response = self._open(req, data)
File "/usr/lib/python3.5/urllib/request.py" in _open
489. 'unknown_open', req)
File "/usr/lib/python3.5/urllib/request.py" in _call_chain
444. result = func(*args)
File "/usr/lib/python3.5/urllib/request.py" in unknown_open
1324. raise URLError('unknown url type: %s' % type)
Exception Type: URLError at /payment/ps/pay/
Exception Value: <urlopen error unknown url type: https>
这是我第一次使用泡沫,所以也许我犯了一个愚蠢的错误 我在做什么错?有更好的方法用 python 发送肥皂动作?
【问题讨论】:
标签: python web-services soap suds