5
A
回答
8
是的,我已經在某些情況下做到了這一點,在這種情況下SOAPpy不能與給定的模式一起工作。這應該讓你開始。
import httplib
from xml.dom import minidom
http.request("POST", "/path/to/my/webservice", body=xml, headers = {
"Host": "myservername",
"Content-Type": "text/xml; charset=UTF-8",
"Content-Length": len(xml)
})
print minidom.parseString(http.getresponse().read())
對於內容字符串,我會用SoapUI手動發出請求,然後模仿XML。
3
是的,見http://www.w3schools.com/SOAP/soap_httpbinding.asp
甲SOAP方法是HTTP 請求/響應與 SOAP編碼規則的規定。
HTTP + XML = SOAP
的SOAP請求可以是HTTP POST 或HTTP GET請求。
有時您會發現其他傳輸機制,例如使用消息傳遞框架,這些傳輸機制用於服務質量的原因。
0
我在simple-salesforce包中發現了一個很好的例子。代碼是在login.py
和粘貼在
soap_url = 'https://{domain}.salesforce.com/services/Soap/u/{sf_version}'
domain = 'test' if sandbox else 'login'
soap_url = soap_url.format(domain=domain, sf_version=sf_version)
username = escape(username)
password = escape(password)
# Check if token authentication is used
if 'security_token' in kwargs:
security_token = kwargs['security_token']
# Security Token Soap request body
login_soap_request_body = """<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<n1:login xmlns:n1="urn:partner.soap.sforce.com">
<n1:username>{username}</n1:username>
<n1:password>{password}{token}</n1:password>
</n1:login>
</env:Body>
</env:Envelope>""".format(username=username, password=password, token=security_token)
# Check if IP Filtering is used in cojuction with organizationId
elif 'organizationId' in kwargs:
organizationId = kwargs['organizationId']
# IP Filtering Login Soap request body
login_soap_request_body = """<?xml version="1.0" encoding="utf-8" ?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:partner.soap.sforce.com">
<soapenv:Header>
<urn:CallOptions>
<urn:client>RestForce</urn:client>
<urn:defaultNamespace>sf</urn:defaultNamespace>
</urn:CallOptions>
<urn:LoginScopeHeader>
<urn:organizationId>{organizationId}</urn:organizationId>
</urn:LoginScopeHeader>
</soapenv:Header>
<soapenv:Body>
<urn:login>
<urn:username>{username}</urn:username>
<urn:password>{password}</urn:password>
</urn:login>
</soapenv:Body>
</soapenv:Envelope>""".format(
username=username, password=password, organizationId=organizationId)
else:
except_code = 'INVALID AUTH'
except_msg = 'You must submit either a security token or organizationId for authentication'
raise SalesforceAuthenticationFailed(except_code, except_msg)
login_soap_request_headers = {
'content-type': 'text/xml',
'charset': 'UTF-8',
'SOAPAction': 'login'
}
response = requests.post(soap_url,
login_soap_request_body,
headers=login_soap_request_headers,
proxies=kwargs.get('proxies', None))
相關問題
- 1. 用Django發送SOAP請求
- 2. 使用php發佈SOAP請求
- 3. 我可以使用urllib提交SOAP請求嗎?
- 4. 我可以使用HTTP HEAD請求發佈表單數據嗎?
- 5. 我可以修改通過SOAP請求
- 6. 發送SOAP請求
- 7. 我可以發出僅使用HTTP/2的HTTP請求嗎?
- 8. 使用http build創建soap請求
- 9. 使用JSON進行HTTP POST SOAP請求
- 10. SOAP HTTP請求很慢
- 11. 用c發送SOAP請求#
- 12. 發送SOAP請求用Matlab
- 13. 帶有SOAP級別認證和HTTP認證的Onvif SOAP請求
- 14. 如何從PHP發佈SOAP請求
- 15. HTTP身份驗證和SOAP請求
- 16. Axis:log SOAP http請求和響應
- 17. SOAP,HTTP Web服務請求和URL
- 18. 使用PHP的SOAP請求
- 19. 使用groovy的SOAP請求
- 20. 使用PHP的SOAP請求
- 21. 使用PHP的SOAP請求
- 22. 使用nodejs的SOAP請求
- 23. 我可以使用PHP的SoapClient來解析SOAP響應,而無需發出HTTP請求嗎?
- 24. 使用org.apache.http發送帶有SOAP動作的HTTP Post請求
- 25. 如何使用soapui發送SOAP請求
- 26. 使用java向WebService發出SOAP請求
- 27. 使用libcurl發送SOAP請求
- 28. XML SOAP消息的HTTP HTTP發佈
- 29. SOAP請求/響應/使用
- 30. Xcode發送HTTPS Soap請求
斷開的鏈接 - 只是擡起頭來。 – alexplanation 2014-01-17 21:51:06