Web Service系列之实例之使用urllib发送SOAP POST请求
原文链接: http://www.kylin-ux.com/2017/04/21/network-web-web-service系列之实例之使用urllib发送SOAP-POST请求
完整代码:
|
|
headers = {'Content-Type': 'text/xml'}
若headers = {}
则Unsupported Content-Type: application/x-www-form-urlencoded
若headers = {'Content-Type': 'application/soap+xml; charset=utf-8'}
则Unsupported Content-Type: application/soap+xml; charset=utf-8
另外
The processing instruction target matching “[xX][mM][lL]” is not allowed
是因为content can't start with a space
输出结果:
|
|
问题:
那么, data_jaxws
和data_spyne
中的名字空间和参数名的值从哪里取呢?
名字空间
名字空间的值取自wsdl(如http://localhost:8000/?wsdl
)的<definitions>
或<wsdl:definitions>
节点中xmlns:tns
或targetNamespace
的值
如,12xmlns:tns="spyne.examples.hello.soap"targetNamespace="spyne.examples.hello.soap"参数
参数名取自wsdl的<wsdl:types>
节点
如,12345678910<wsdl:types><xs:schema targetNamespace="spyne.examples.hello.soap" elementFormDefault="qualified"><xs:complexType name="stringArray"><xs:sequence><xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded" nillable="true"/></xs:sequence></xs:complexType>... ...</xs:schema></wsdl:types>