<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
dim url,soaprequest,retvalue
soaprequest="type=1"
set xmlhttp = server.createobject("msxml2.xmlhttp")
xmlhttp.open "post","http://localhost/testservice.asmx/AddOrder",false
xmlhttp.setrequestheader "content-type", "application/x-www-form-urlencoded"
xmlhttp.setrequestheader "host",host
xmlhttp.setrequestheader "content-length",len(soaprequest)
xmlhttp.send(soaprequest)
'response.write(xmlhttp.status)
if xmlhttp.status = 200 then
set xmldoc = server.createobject("msxml2.domdocument")
'xmldoc.load(xmlhttp.responsexml)
response.write(xmlhttp.responsetext)
'xmldoc是接收了webservice返回的xml内容,如果webservice返回的不是xml,就用xmlhttp.responsetext
else
'调用webservice失败
end if
set xmlhttp = nothing
%>
<%
dim url,soaprequest,retvalue
soaprequest="type=1"
set xmlhttp = server.createobject("msxml2.xmlhttp")
xmlhttp.open "post","http://localhost/testservice.asmx/AddOrder",false
xmlhttp.setrequestheader "content-type", "application/x-www-form-urlencoded"
xmlhttp.setrequestheader "host",host
xmlhttp.setrequestheader "content-length",len(soaprequest)
xmlhttp.send(soaprequest)
'response.write(xmlhttp.status)
if xmlhttp.status = 200 then
set xmldoc = server.createobject("msxml2.domdocument")
'xmldoc.load(xmlhttp.responsexml)
response.write(xmlhttp.responsetext)
'xmldoc是接收了webservice返回的xml内容,如果webservice返回的不是xml,就用xmlhttp.responsetext
else
'调用webservice失败
end if
set xmlhttp = nothing
%>
asp.net
webservice
using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
/// <summary>
///testservice 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class testservice : System.Web.Services.WebService
{
public testservice()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod(Description = "测试调用webservice")]
public string AddOrder(int type)
{
string result = "";
switch (type)
{
case 0:
result = "Hello World";
break;
default :
result = "Hello Yike";
break;
}
return result;
}
}
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
/// <summary>
///testservice 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
public class testservice : System.Web.Services.WebService
{
public testservice()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod(Description = "测试调用webservice")]
public string AddOrder(int type)
{
string result = "";
switch (type)
{
case 0:
result = "Hello World";
break;
default :
result = "Hello Yike";
break;
}
return result;
}
}