files\sybase\shared\powerbuilder下面的pbsoapclient90.pbd加入target.
2.創建web service代理
點:File->News->Project->Web service Proxy
Wizrd
下壹步會提示妳輸入WSDL文件,點擊瀏覽選擇webservice服務器端提供的wsdl接口文檔,比如(附檔wsdl.rar):
http://172.18.60.39:8080/person/wsdl
點擊下壹步,會自動出現WSDL文件中的Service.點擊下壹步,系統默認選擇ServiceSoap,緊接著輸入proxy name(代理對象名)前綴,輸入My.後面的幾項按默認即可。
完成後是編譯代理對象的界面。會出現:
Web Service Generator Project Status
Deployment PBL:
E:\whz\PBWebService\pb9\smsweb.pbl
Clear PBL on build: No
Confirm
overwrites: No
WSDL Location:
http://172.18.60.39:8080/person/wsdl
Services selected :
Service
Service:
PersonPort
點擊編譯的綠色圖標,壹個代理對象(mypersonport)生成了。
3.增加壹個窗口放壹個按鈕,調用代碼樣例:
SoapConnection lsc_conn
mypersonport
lproxy_obj
String ls_proxy_name = "mypersonport"//生成的代理對象名稱
String
ls_url =
"http://172.18.60.39:8080/person/api"//這個url從wsdl接口文檔<service>節點可以找到
int
li_ret, i
try
lsc_conn = Create SoapConnection
//lsc_conn.SetOptions("SoapLog=~"soaplog.txt~"")
li_ret =
lsc_conn.Createinstance(lproxy_obj,ls_proxy_name,ls_url)
If li_ret
<> 0 Then
MessageBox("錯誤", "調用失敗,錯誤代碼:" + String(li_ret))
Return
End If
i = lproxy_obj.add("1")
MessageBox("Web Service", "調用成功:" + String(i))
catch (SoapException
e1)
MessageBox("錯誤", "不能調用函數,錯誤信息:" + e1.GetMessage())
catch
(PBXRuntimeError e2)
MessageBox("錯誤", "調用函數運行時錯誤." )
catch
(RuntimeError e3)
MessageBox("錯誤", "調用函數不可知錯誤." )
end try