直接用Qt写soap
直接用Qt写soap
原理
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtNetwork import *
class MainWindow(QMainWindow):
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self._http = None
self.test()
def test(self):
http = QHttp('10.88.104.158')
self._http = http
data = '''<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<UserLogin xmlns="http://www.richfit.com/">
<userLoginName>admin</userLoginName>
<userPwd>123</userPwd>
<appType>test</appType>
</UserLogin>
</soap:Body>
</soap:Envelope>'''
req = QHttpRequestHeader()
req.setRequest('POST', '/3DWebGIS/Services/DataService.asmx')
req.setValue('Host', '10.88.104.158')
req.setValue('Content-Type', 'text/xml; charset=utf-8')
req.setValue('Content-Length', str(len(data)))
req.setValue('SOAPAction', '"http://www.richfit.com/UserLogin"')
self.connect(self._http, SIGNAL('requestFinished(int, bool)'), self.finish)
cnt = data.encode('utf-8')
print http.request(req, cnt)
def test1(self):
import sys, httplib
data = '''<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<UserLogin xmlns="http://www.richfit.com/">
<userLoginName>admin</userLoginName>
<userPwd>123</userPwd>
<appType>test</appType>
</UserLogin>
</soap:Body>
</soap:Envelope>'''
h = httplib.HTTP('10.88.104.158')
h.putrequest('POST', '/3DWebGIS/Services/DataService.asmx')
h.putheader('Host', '10.88.104.158')
h.putheader('User-Agent', 'Python post')
h.putheader('Content-Type', 'text/xml; charset="UTF-8"')
h.putheader('Content-length', str(len(data)))
h.putheader('SOAPAction', '"http://www.richfit.com/UserLogin"')
h.endheaders()
h.send(data)
sc, sm, header = h.getreply()
print sc, sm
print header
print h.getfile().read()
def finish(self, iid, ok):
print iid, ok
resp = self._http.lastResponse()
print resp.statusCode(), resp.reasonPhrase()
print str(self._http.readAll()).decode('utf-8')
app = QApplication(sys.argv)
frm = MainWindow()
frm.show()
app.exec_()
h = httplib.HTTP('10.88.104.158')
直接用Qt写soap的更多相关文章
- 这个程序员有点牛,现场直接用JS写了个飞机游戏,半小时吸粉三千
程序员昨晚在b站直播的时用JavaScript代码写了一个飞机大战游戏,半小时不到粉丝关注就上千了. 今日就拿出来跟大家分享一下,对许多大佬来说做这个特效也不是很难,但是对于刚开始学习前端这方面还是有 ...
- Java中 util 包 Calendar类制作万年历(不用自己写方法,直接用Java写好的包中的类的方法)
代码前需要了解的关于Calendar类的内容: 1.在util包中,首先要知道Calendar 提供了一个类方法 getInstance,以获得此类型的一个通用的对象.Calendar 的 ...
- Qt写Activex插件 总结
最近写的插件功能基本完成,也遇到了一些坑,在这里记录一下. 我写的这个插件的js接口是仿造google earth的js接口,尽可能的达到与它的api一致.先从最简单的说起: 1. 导出接口中的flo ...
- 只用@property定义一个属性speed,子类不能直接用_speed,需要在interface的成员变量列表里写上_speed
//写法一: @interface Person : NSObject { } @property (nonatomic, strong) NSString *name; @end @implemen ...
- 每日学习笔记:js中可以直接用id名调用的问题?
在JavaScript中,标准的id选择器调用语法是: document.getElementById('myid').style.width = pc + "%"; 但是,今天发 ...
- 为什么是List list = new ArrayList() 而不直接用ArrayList
为什么是List list = new ArrayList(),而不直接用ArrayList? 编程是要面向对象编程,针对抽象(接口),而非具体.List 是接口,ArrayList是实现. 实现Li ...
- 直接用nose进行django项目测试并输出html报告
先说需求:1.测试django项目:2.打印测试报告(html格式)有以下几种测试方法:1.django自带的测试模块.在app目录下的tests.py文件中写测试类,类似这样: class MyTe ...
- less是什么?直接用css好还是less好
问:Less是一个动态CSS语言框架,Less扩展了CSS的动态特性 [1]:从实现角度来说,直接用css看起来能方便一些,而less还要编译? [2]:技术上好像灵活,但是从使用者的角度来说,css ...
- Netty为什么不直接用AtomicXXX,而要用AtomicXXXFieldUpdater去更新变量呢?
更多技术分享可关注我 前言 如果仔细阅读过Netty的线程调度模型的源码,或者NIO线程对象及其线程池的创建源码,那么肯定会遇到类似“AtomicIntegerFieldUpdater”的身影,不禁想 ...
随机推荐
- CXF学习 (1)
Axis(Apache) -> Axis2(Apache) XFire - > CXF (XFire+Celtrix) (Apache) CXF并不仅仅是Webservice框架,更号称是 ...
- <转>Java 常用排序算法小记
排序算法很多地方都会用到,近期又重新看了一遍算法,并自己简单地实现了一遍,特此记录下来,为以后复习留点材料. 废话不多说,下面逐一看看经典的排序算法: 1. 选择排序 选择排序的基本思想是遍历数组的过 ...
- Installing MySQL Server on CentOS
MySQL is an open-source relational database. For those unfamiliar with these terms, a database is wh ...
- 已解决:Strict Standards: Non-static method cls_image::gd_version() should not be called statically in...
在安装Ecshop的时候,遇到两个⚠️问题: Strict Standards: Non-static method cls_image::gd_version() should not be cal ...
- 【MongoDB】2.可视化工具的安装和使用
首先:关于 能支持MongoDB新版本的可视化工具,争议不断,各人都有各人的支持. 因此之前选择安装的时候就安装了MongoDB 3.0.14版本的. 最终,确定使用Robomongo作为我第一个 ...
- WPF VlC 实现视频的播放(1)
WPF 使用VLC实现视频的播放:网上开源代码我复制了一份: https://github.com/someonehan/Vlc.DotNet 1. 准备阶段 (I) libvlc.dll 和 l ...
- 对NLP的一些新认识
其实这是老板让上交的一份总结,贴出来,欢迎朋友们批评指正. 最近看了一部分关于NLP的几篇论文,其中大部分为神经网络实现, 从基本的HMM算法实现,到LSTM实现,有很多方法可以用来处理NLP任务中的 ...
- A - The Moronic Cowmpouter
Description Inexperienced in the digital arts, the cows tried to build a calculating engine (yes, it ...
- JavaScript eval() 函数
定义和用法:eval() 函数可计算某个字符串,并执行其中的的 JavaScript 代码. 语法:eval(string) 参数 描述 string 必需.要计算的字符串,其中含有要计算的 Java ...
- SolrCloud-4.10.2源代码启动流程梳理
SolrCloud-4.10.2源代码 web.xml中filter配置 SolrDispatchFilter <filter-name>SolrRequestFilter</fil ...