博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何在各种开发语言中调用web service
阅读量:2342 次
发布时间:2019-05-10

本文共 3527 字,大约阅读时间需要 11 分钟。

 

方法

〈form target="_blank" action='http://www.ydcom.net/service/S_COMM.asmx/GetCZID' method="POST"〉

〈table cellspacing="0" cellpadding="4" frame="box" bordercolor="#dcdcdc" rules="none" style="border-collapse: collapse;"〉
〈tr〉
〈td class="frmHeader" background="#dcdcdc" style="border-right: 2px solid white;"〉参数〈/td〉
〈td class="frmHeader" background="#dcdcdc"〉值〈/td〉
〈/tr〉
〈tr〉
〈td class="frmText" style="color: #000000; font-weight: normal;"〉sTypeNum:〈/td〉
〈td〉〈input class="frmInput" type="text" size="50" name="sTypeNum"〉〈/td〉
〈/tr〉
〈tr〉
〈td〉〈/td〉
〈td align="right"〉 〈input type="submit" value="调用" class="button"〉〈/td〉
〈/tr〉
〈/table〉
〈/form〉

实例:

相关文档:

<%

Dim url,xmlhttp,dom,node,xmlDOC
'根据webservice的测试页不同的方法构造不同的soap request
SoapRequest = " "& _
" " "& _
" "& _
" 311 "& _
" "& _
" "& _
""
url = "http://www.ydcom.net/service/S_COMM.asmx?methodname=GetCZID"
Set xmlDOC =server.CreateObject("MSXML.DOMDocument")
xmlDOC.loadXML(SoapRequest)
Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
xmlhttp.Open "POST",url,false
xmlhttp.setRequestHeader "Content-Type", "text/xml;charset=utf-8"
xmlhttp.setRequestHeader "SOAPAction", "http://www.ydcom.net/service/SrvCOMM/S_COMM/GetCZID"
xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
xmlhttp.Send(xmlDOC)

If xmlhttp.Status = 200 Then

xmlDOC.load(xmlhttp.responseXML)
Response.Write xmlhttp.Status&"
"
Response.Write xmlhttp.StatusText&"
执行结果为:"
Response.Write xmlDOC.getElementsByTagName("GetCZIDResult")(0).text
else
Response.Write xmlhttp.Status&"
"
Response.Write xmlhttp.StatusText
end if
%>

实例:

说明:总的来讲采用webservice的列表页说明来构造不同的SoapRequest,然后,

从返回xmlDoc中取返回值xmlDOC.getElementsByTagName

<%

Set objHTTP = Server.CreateObject("MSXML2.XMLHTTP")
Set xmlDOC =Server.CreateObject("MSXML.DOMDocument")
strWebserviceURL = "http://www.ydcom.net/service/S_COMM.asmx/GetCZID"
'设置参数及其值
strRequest = "sTypeNum=311"
objHTTP.Open "POST", strWebserviceURL, False
'设置这个Content-Type很重要
objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.SetRequestHeader("Content-Length: 30")
objHTTP.Send(strRequest)
bOK = xmlDOC.load(objHTTP.responseXML)
'看看状态值
if objHTTP.Status=200 then
xmlStr = xmlDOC.xml
Response.Write xmlStr
else
Response.Write objHTTP.Statu&"
"
Response.Write objHTTP.StatusText
end if
%>

实例:

Dim strxml As String

Dim str As String
str = Text2.Text
'定义soap消息
strxml = "
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/'> " & str &
" "
'定义一个http对象,一边向服务器发送post消息
Dim h As MSXML2.ServerXMLHTTP40
'定义一个XML的文档对象,将手写的或者接受的XML内容转换成XML对象
Dim x As MSXML2.DOMDocument40
'初始化XML对象
Set x = New MSXML2.DOMDocument40
'将手写的SOAP字符串转换为XML对象
x.loadXML strxml
'初始化http对象
Set h = New MSXML2.ServerXMLHTTP40
'向指定的URL发送Post消息
h.open "POST", "http://localhost/TestWebService/Service1.asmx", False
h.setRequestHeader "Content-Type", "text/xml"
h.send (strxml)
While h.readyState <> 4
Wend
'显示返回的XML信息
Text1.Text = h.responseText
'将返回的XML信息解析并且显示返回值
Set x = New MSXML2.DOMDocument40
x.loadXML Text1.Text
Text1.Text = x.childNodes(1).Text

1,首先添加web引用,地址为:

2,定义:dim sCom as New net.ydcom.www.S_COMM

3,调用:dim strCZID as string = sComm.GetCZID("313")

实例:

SoapConnection conn

Test_wsservice1soap sCom
long rVal
//string str_endpoint
//str_endpoint = ""
conn = create SoapConnection
rVal = Conn.CreateInstance(sCom, "test_wsservice1soap")
sle_1.text = sCom.GetCZID("313"))
destroy conn

转载地址:http://fudvb.baihongyu.com/

你可能感兴趣的文章
GridBagLayout 的注意
查看>>
ajax 跨域iis6 设置
查看>>
4.0版本改动
查看>>
IE8 9 ajax no-transport ajax 问题
查看>>
oracle 启动dbconsole
查看>>
entity-framework 6解决方案中多个项目使用
查看>>
ios基础
查看>>
unity3d
查看>>
metronic 1.5
查看>>
unity3d 4 assert store
查看>>
tab bar control 注意事项
查看>>
sql优化部分总结
查看>>
IDEA运行时动态加载页面
查看>>
UML总结(对九种图的认识和如何使用Rational Rose 画图)
查看>>
js遍历输出map
查看>>
easeui分页
查看>>
20个非常有用的Java程序片段
查看>>
Enterprise Architect使用教程
查看>>
Enterprise Architect 生成项目类图
查看>>
浅入深出 MySQL 中事务的实现
查看>>