Web服务在服务器端不起作用

时间:2013-01-17 05:42:00

标签: c# asp.net .net web-services asmx

我创建了一个名为test.asmx的名为[WebService(Namespace = "http://insforia.com/Webservices/StockTickers/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [WebMethod(Description = "Using stock symbol gets delayed stock information from Yahoo.", EnableSession = false)] public string[] GetQuote() { string username = Session["username"].ToString(); string company = "BSE-100.BO+COALINDIA.BO+TCS.BO+WIPRO.BO+SBIN.NS+MNM.BO+RCOM.BO+TATASTL.BO+GMRINFRA.BO+ICICIBANK.BO"; string stockcodes = "sl1c6"; string url = "http://in.finance.yahoo.com/d/quotes.csv?s=" + company + "&f=" + stockcodes; var webRequest = HttpWebRequest.Create(url); var webResponse = webRequest.GetResponse(); using (StreamReader sr = new StreamReader(webResponse.GetResponseStream())) { buffer = sr.ReadToEnd(); } var buffer = buffer.Replace("\"", ""); buffer = buffer.Replace("\r\n", ","); var bufferList = buffer.Split(new char[] { ',' }); return bufferList; } 的bservice,如下所示:

private string userid = "admin";

protected void Page_Load(object sender, EventArgs e)
{
     Session["username"] = userid;
     test oo = new test();
     bufferList = oo.GetQuote();
}

我正在我的aspx页面中调用此Web服务,如下所示:

test

事情是它在我的localhost中完美运行但是当我将它上传到服务器上时它给了我一个错误,它无法找到http://insforia.com/Webservices/StockTickers/stockmain.aspx

查看确切错误,这是链接:

{{1}}

我不明白该怎么办?为什么会这样。我知道这是一个非常愚蠢的问题,但我从昨天开始尝试这个问题。

1 个答案:

答案 0 :(得分:0)

尽量不要使用session。 发送用户名的参数;

public string[] GetQuote(string UserName)
{
...
    return bufferList;
}