今天分享个常用webservice调用方式

1.创建一个工作空间和Application,添加1个pbd包,再在pb目录中可以找到,我的在这里面(D:\Program Files (x86)\Sybase\Shared\PowerBuilder)PB11调用webservice详解
2.创建 Web Service Proxy Wizard一直next到
PB11调用webservice详解
wsdl地址:http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl

又是一直next到
PB11调用webservice详解
选择当前pbl,然后又是一直next,会自动生成如下
PB11调用webservice详解
右键Deploy部署,需要关闭打开的窗口
自动生成
PB11调用webservice详解
服务端对象和参数

3.创建一个窗口实现如下效果
PB11调用webservice详解
4.编写查询按钮点击事件
soapconnection lnv_soap
mobilecodewssoap lnv_ms
String ls_result
String ls_errtext
String ls_tel

lnv_soap = create soapconnection
lnv_soap.createinstance(lnv_ms,“mobilecodewssoap”,“http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx”)

ls_tel = sle_tel.text
try
ls_result = lnv_ms.getmobilecodeinfo(ls_tel, “”)
catch(soapexception ex)
ls_errtext = ex.text
ls_result = “错误”
end try

if ls_result = “错误” then
messagebox(“调用webservice失败”,ls_errtext)
return
end if

messagebox(“调用webservice成功”,ls_result)

destroy lnv_soap

5.完成,效果如图
PB11调用webservice详解
这里还用了一个定时器函数timer显示当前时间
PB11调用webservice详解

相关文章: