Web Service系列之实例之使用http.client发送SOAP POST请求
来源:互联网 发布:字符串压缩 java 编辑:程序博客网 时间:2024/06/05 07:20
原文链接: Web Service系列之实例之使用http.client发送SOAP POST请求
本文只给出代码, 更多内容请查看本系列另外一篇文章, Web Service系列之实例之使用urllib发送SOAP POST请求
完整代码:
import sys, http.clientimport urllib.requesthost = "localhost:9000"SM_TEMPLATE = """<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:EnvelopeSOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><ns1:helloWorld xmlns:ns1="http://webservice.kylinux.com/"><arg0>%s</arg0><arg0>%s</arg0></ns1:helloWorld></SOAP-ENV:Body></SOAP-ENV:Envelope>"""SoapMessage = SM_TEMPLATE%("Kylin", "Shu")#print(SoapMessage)#construct and send the headerwebservice = http.client.HTTPConnection(host)headers = {"Content-type": "text/xml; charset=\"UTF-8\""}webservice.request("POST", "/WS/HelloWorld/", body=SoapMessage, headers=headers)#headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}response = webservice.getresponse()#print(response.status, response.reason)data = response.read()print(data)webservice.close()
1 0
- Web Service系列之实例之使用http.client发送SOAP POST请求
- Web Service系列之实例之使用urllib发送SOAP POST请求
- Http学习之使用HttpURLConnection发送post和get请求
- Http学习之使用HttpURLConnection发送post和get请求
- Http学习之使用HttpURLConnection发送post和get请求
- Http学习之使用HttpURLConnection发送post请求深入
- Http学习之使用HttpURLConnection发送post和get请求
- Http学习之使用HttpURLConnection发送post请求深入
- Http学习之使用HttpURLConnection发送post和get请求
- Http学习之使用HttpURLConnection发送post和get请求
- Http学习之使用HttpURLConnection发送post和get请求
- Http学习之使用HttpURLConnection发送post和get请求
- Http学习之使用HttpURLConnection发送post和get请求 .
- Http学习之使用HttpURLConnection发送post请求深入 .
- Http学习之使用HttpURLConnection发送post和get请求
- Http学习之使用HttpURLConnection发送post请求深入
- Http学习之使用HttpURLConnection发送post和get请求
- Http学习之使用HttpURLConnection发送post请求深入
- 注册表及其CRegKey类
- [编程题]字符串最后一个单词的长度
- POJ2186 Popular Cows 【强连通分量】+【Kosaraju】+【Tarjan】
- jz2440一些接口注意事项
- linux内存管理基本概念
- Web Service系列之实例之使用http.client发送SOAP POST请求
- Jquery中的offset()和position()的区别
- Java基础学习笔记:(十)static关键字
- mybatis总结(4)---Mybatis 开发DAO两种方法
- JAVA界面 Swing
- 人才推荐系统API接口文档
- 三十四、SpringBoot配置属性之Server
- Javascript面向对象(七)——类模式
- jdGrid参数说明