如何调用wbeServer中的方法并直接取得回传的XML(付出错代码)
如下
.net中自己设的wbeServer
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections;
using shop.BLL;
using shop.Model;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod]
public ArrayList DoShopping(string uid, string pwd, string subMoney)
{
decimal subMoneys = decimal.Parse(subMoney);
ArrayList al = Shopping.DoShopping_bll(uid, pwd, subMoneys);
return al;
}
}
想要调用里面的方法并取得返回值的XML:
[WebMethod]
public ArrayList DoShopping(string uid, string pwd, string subMoney)
{
decimal subMoneys = decimal.Parse(subMoney);
ArrayList al = Shopping.DoShopping_bll(uid, pwd, subMoneys);
return al;
}
前台页面脚本中的请求时调用的函数:
function checkInfo()
{
var reg = /^\d{1,4}$/;
var money = document.getElementById("money").value;
var uid = document.getElementById("uid").value;
var pwd = document.getElementById("pwd").value;
if(reg.test(money))
{
xHRObject.abort();
xHRObject.open("GET","Default.aspx?uid=" + uid + "&pwd=" + pwd + "&money=" + money + "&values=" + Number(new Date),true);
xHRObject.onreadystatechange = getData;
xHRObject.send(null);
}
else
{
alert("input number(0~9999)");
document.getElementById("money").value="";
}
}
另有getData()方法用来接serverResponse
脚本中请求调用的代理页面
using System;
using System.Data;
using System.Configuration;