我用的是PB9.0 调用webservice 时,如果url 是地址正确的情况下,没有问题,如果 url 地址错误,或 web服务器没有启动。PB 就会报错,点确定后程序就全关了。有没有什么办法提示一下,如果地址错误或服务器没有连上,点确定后返回。。。
如下是错误的提示。
---------------------
powerbuilder application Execution Error(Roooo)
X application terminated
Error:Failed to connect to host 127.0.0.1,port 8888: NO error
确定
---------------------------
上边是出错窗口,
下边的按钮下的代码:
-------------------------------
SoapConnection conn
publicwebservicepublicinterface public_ws
string ls_url
long rVal
string str_endpoint,s_xml
ls_url=trim(sle_1.text)
str_endpoint = "http://127.0.0.1:8888/interface/services/PublicInterface?wsdl"
conn = create SoapConnection
s_xml=trim(mle_1.text)
rVal = Conn.CreateInstance(public_ws,"publicwebservicepublicinterface",ls_url)
if rval <> 0 then
messagebox('提示:','连接网络URL 出现错误,错误代码: '+string(rval))
end if
mle_2.text = public_ws.getMemberInfo(s_xml)
destroy conn
------解决方案--------------------
pb9你可以加上try catch
try
rVal = Conn.CreateInstance(public_ws,"publicwebservicepublicinterface",ls_url)
catch (runtimeerror re)
messagebox('提示:','连接网络URL 出现错误,错误代码: '+string(rval))
end try