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