我正在尝试连接A Broadsoft OCI-P,它接受XML到CRUD用户订阅等。 我需要的操作是一个身份验证请求,我请求登录,我收到一个nonce,生成一个MD5响应然后将被允许继续。 我发送初始请求,我可以看到Nonce通过tcpdump(wireshark)返回。 python请求或httplib2都没有收到nonce的完整响应。 (我已经使用bash管理了完整的身份验证。)
有没有人知道为什么我没有收到完整的回复?这是' \ n'在回应?如果是这样,我该怎么办呢?
由于 中号
try:
print('Using the Requests Module')
headers={'cache-control':'no-cache', 'Accept-Encoding':'ISO-8859-1', 'content-type':'text/xml; charset=ISO-8859-1','Accept': 'application/soap+xml, application/dime, multipart/related, text/*', }
encoded_body = make_payload()
r = requests.post('http://10.*.*.*:2208', data = encoded_body,\
headers = headers, auth = ('admin', 'admin'))
except requests.exceptions.RequestException as e:
<?xml version="1.0" encoding="ISO-8859-1"?>
<BroadsoftDocument protocol = "OCI" xmlns="C" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sessionId xmlns="">DJ1U3ZFW54J9068R1YDNOE0CNSICCTJS</sessionId>
<command xsi:type="AuthenticationRequest" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<userId>admin</userId>
</command>
</BroadsoftDocument>
('Connection aborted.', BadStatusLine('<?xml version="1.0" encoding="ISO-8859-1"?>\n',))
跟踪来自原始机器的Wireshark:
POST / HTTP/1.1
Host: 10.*.*.*:2208
Connection: keep-alive
Accept-Encoding: ISO-8859-1
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: python-requests/2.12.4
content-type: text/xml; charset=ISO-8859-1
cache-control: no-cache
Content-Length: 376
Authorization: Basic YWRtaW46YWRtaW4=
<?xml version="1.0" encoding="ISO-8859-1"?>
<BroadsoftDocument protocol = "OCI" xmlns="C" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sessionId xmlns="">DJ1U3ZFW54J9068R1YDNOE0CNSICCTJS</sessionId>
<command xsi:type="AuthenticationRequest" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<userId>admin</userId>
</command>
</BroadsoftDocument>
<?xml version="1.0" encoding="ISO-8859-1"?>
<BroadsoftDocument protocol="OCI" xmlns="C" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sessionId xmlns="">DJ1U3ZFW54J9068R1YDNOE0CNSICCTJS</sessionId>
<command echo="" xsi:type="AuthenticationResponse" xmlns="">
<userId>admin</userId>
<nonce>1483616534128</nonce>
<passwordAlgorithm>MD5</passwordAlgorithm>
</command>
我在httplib2上遇到了类似的错误:
send: 'POST / HTTP/1.1\r\nHost: 10.xxx.xxx.198:2208\r\nContent-Length: 376\r\nuser-agent: Python-httplib2/0.9.2 (gzip)\r\ncontent-type: text/xml; charset=ISO-8859-1\r\naccept-encoding: ISO-8859-1\r\naccept: application/soap+xml, application/dime, multipart/related, text/*\r\ncache-control: no-cache\r\n\r\n<?xml version="1.0" encoding="ISO-8859-1"?>
<BroadsoftDocument protocol = "OCI" xmlns="C" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sessionId xmlns="">TNN80U63D56CMMB8DV929UZT22177EAZ</sessionId>
<command xsi:type="AuthenticationRequest" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<userId>admin</userId>
</command>
</BroadsoftDocument>'
reply: '<?xml version="1.0" encoding="ISO-8859-1"?>\n'
try:
print('Starting stage httplib2')
encoded_body = make_payload()
http_agent = httplib2.Http(cache=None, timeout= 5, disable_ssl_certificate_validation=True)
httplib2.debuglevel = 1
response,response_body= http_agent.request('http://10.*.*.*:2208', \ method="POST", body=encoded_body, headers={'cache-control':'no-cache', 'Accept-Encoding':'ISO-8859-1', 'content-type':'text/xml; charset=ISO-8859-1','Accept': 'application/soap+xml, application/dime, multipart/related, text/*', })
print (response, response_body)
except:
...