转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
如何在各种开发语言中调用web service         ★★★★

如何在各种开发语言中调用web service

作者:闵涛 文章来源:闵涛的学习笔记 点击数:875 更新时间:2009/4/23 18:34:07

方法

〈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〉

实例:如何调用服务产生18位关键值

相关文档: 使用vbscript脚本调用web服务


<%
Dim url,xmlhttp,dom,node,xmlDOC
''''根据webservice的测试页不同的方法构造不同的soap request
SoapRequest = ""& _
""xmlns:xsd="&CHR(34)&"http://www.w3.org/2001/XMLSchema"&CHR(34)&" "& _
"xmlns:soap="&CHR(34)&"http://schemas.xmlsoap.org/soap/envelope/"&CHR(34)&">"& _
""& _
""& _
"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
%>

实例:如何使用asp调用服务产生18位关键值 asp源文件代码

说明:总的来讲采用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
%>

实例:如何使用asp调用服务产生18位关键值 asp源文件代码


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引用,地址为:http://www.ydcom.net/service/s_comm.asmx

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

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

实例:如何使用VB.NET调用服务产生18位关键值 VB.NET源文件代码


SoapConnection conn
Test_wsservice1soap sCom
long rVal
//string str_endpoint
//str_endpoint = "http://www.ydcom.net/service/s_comm.asmx?WSDL"
conn = create SoapConnection
rVal = Conn.CreateInstance(sCom, "test_wsservice1soap")
sle_1.text = sCom.GetCZID("313"))
destroy conn


[常用软件]过期踢出域名服务(Expire Domain Service)  [VB.NET程序]vb.net控件、web service简述
[Delphi程序]李维:樂趣無窮,可能無限的新技術-Web Service  [Delphi程序]一步一步用Delphi6实现Web Service
[Delphi程序]什么是Web Service  [Delphi程序]编写一个单独的Web Service for Delphi7(步骤)
[Delphi程序]为Windows Service添加服务描述  [Delphi程序]Delphi开发NT Service程序
[Delphi程序]TPanel 在使用 Theme Service 时的 Bug  [Delphi程序]关于C#下写的Web Service 服务在Delphi下调用时的…
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台