Web服务无法正常工作在服务器端
问题描述:
我已经创建了一个名为test.asmx
一个我们bservice它看起来像这样:Web服务无法正常工作在服务器端
[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;
}
和我打电话像这样在我的aspx页面此Web服务:
private string userid = "admin";
protected void Page_Load(object sender, EventArgs e)
{
Session["username"] = userid;
test oo = new test();
bufferList = oo.GetQuote();
}
东西是它在我的本地主机完美工作,但当我上传到服务器上它给我一个错误,它找不到test
看到确切的错误,这是链接:
http://insforia.com/Webservices/StockTickers/stockmain.aspx
我不明白该怎么办?为什么发生这种情况。我知道这是一个非常愚蠢的问题,但我从昨天开始尝试。
答
尝试不使用会话。 发送用户名的参数;
public string[] GetQuote(string UserName)
{
...
return bufferList;
}
什么是您的测试课程? – TheWhiteRabbit