asp.net 调用本地webservice 报500错误

wwfgu00ing 2012-01-04 09:21:18
调用方法如下:
var url = "http://192.168.1.222:95/IPay.asmx/UppOrder";

var values = new System.Collections.Specialized.NameValueCollection();
values.Add("PayID", TextBox8.Text.Trim());
values.Add("Order", TextBox9.Text.Trim());
values.Add("PayMoney", TextBox10.Text.Trim());
values.Add("PayIP", TextBox11.Text.Trim());
values.Add("UnionID", TextBox12.Text.Trim());

string _str = "";
var client = new WebClient();

byte[] data = client.UploadValues(url, "POST", values); //提交方式
_str = Encoding.UTF8.GetString(data); //编码方式
Response.Write(_str);


之后就报:

--------------------------------------------------------------------------------

远程服务器返回错误: (500) 内部服务器错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Net.WebException: 远程服务器返回错误: (500) 内部服务器错误。

该如何解决
...全文
2367 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
it_huisheng 2014-02-18
  • 打赏
  • 举报
回复
同求啊,我调用java webservice也是一样,一直在出远程服务器返回错误:(500)内部服务器错误,代码如下: string ret = string.Empty; try { string Url = "http://10.162.133.203:8080/web/services/TerminalQueryService"; string hphm = "wsdl"; Encoding encoding = Encoding.GetEncoding("UTF-8"); string postData = hphm; byte[] data = encoding.GetBytes(postData); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url+"?"+hphm); request.Method = "POST"; request.CookieContainer = cookie; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (Stream newStream = request.GetRequestStream()) { newStream.Write(data, 0, data.Length); using (HttpWebResponse res = (HttpWebResponse)request.GetResponse()) { using (StreamReader sr = new StreamReader(res.GetResponseStream(), encode)) { ret = sr.ReadToEnd(); } } } cookie = request.CookieContainer; Console.WriteLine(cookie.ToString()); } catch (WebException ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } return ret;
lostindream 2013-11-16
  • 打赏
  • 举报
回复
我的现在也还是解决不了啊
IfNotMe_1989 2013-08-12
  • 打赏
  • 举报
回复
webservice程序写的有问题,跟你没关系!
色拉油 2012-01-04
  • 打赏
  • 举报
回复
用firebug看看出错信息或者直接调试一下,500一般是你service处理错误,还有一种可能就是你service的返回值与ajax的dataType格式不一致
铜臂阿铁木 2012-01-04
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 wwfgu00ing 的回复:]
引用 6 楼 sunzongbao2007 的回复:
引用 5 楼 wwfgu00ing 的回复:
表头信息是

回应标头信息 - http://localhost:28800/Default.aspx

Server: ASP.NET Development Server/10.0.0.0
Date: Wed, 04 Jan 2012 01:42:14 GMT
X-AspNet-……
[/Quote]
500错误一般都是web.config错误或者webservice处理上的错误,http://192.168.1.222:95/IPay.asmx 这个直接访问会返回个xml吧应该。访问这个地址只是看看这个服务是否正常开启。如果直接在浏览器打开这个asmx能够成功,那说明不是传参问题就是参数接收后处理的逻辑错误。
wwfgu00ing 2012-01-04
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 sunzongbao2007 的回复:]
引用 5 楼 wwfgu00ing 的回复:
表头信息是

回应标头信息 - http://localhost:28800/Default.aspx

Server: ASP.NET Development Server/10.0.0.0
Date: Wed, 04 Jan 2012 01:42:14 GMT
X-AspNet-Version: 2.0.50727
Cache-Co……
[/Quote]
恩 http://192.168.1.222:95/IPay.asmx 这个只是一个简单的webservice 输出一个json字符串
铜臂阿铁木 2012-01-04
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 wwfgu00ing 的回复:]
表头信息是

回应标头信息 - http://localhost:28800/Default.aspx

Server: ASP.NET Development Server/10.0.0.0
Date: Wed, 04 Jan 2012 01:42:14 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-……
[/Quote]

不是已经200了么?Connection 在Http 1.0的时候是指定是否需要长连接的。1.1自动长连接。
所以加上200的statuscode,应该这个页面没什么问题吧。

关键是http://192.168.1.222:95/IPay.asmx 这个地址,看看什么效果。
wwfgu00ing 2012-01-04
  • 打赏
  • 举报
回复
表头信息是

回应标头信息 - http://localhost:28800/Default.aspx

Server: ASP.NET Development Server/10.0.0.0
Date: Wed, 04 Jan 2012 01:42:14 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 2954
Connection: Close

200 OK

连接状态关闭了 怎么解决啊
铜臂阿铁木 2012-01-04
  • 打赏
  • 举报
回复
[Quote=引用楼主 wwfgu00ing 的回复:]
调用方法如下:
var url = "http://192.168.1.222:95/IPay.asmx/UppOrder";

var values = new System.Collections.Specialized.NameValueCollection();
values.Add("PayID", TextBox8.Text.Trim());
values……
[/Quote]

http://192.168.1.222:95/IPay.asmx 直接打开这个地址看看能不能好使,不好使的话应该是服务端的配置有误或者逻辑出异常了。
wwfgu00ing 2012-01-04
  • 打赏
  • 举报
回复
我 这里 调用的是一个webservice 网上大都是一个url传参
满衣兄 2012-01-04
  • 打赏
  • 举报
回复
_str能不能直接在浏览器里访问呢?
cf_nxcxy 2012-01-04
  • 打赏
  • 举报
回复
是服务端异常
阿非 2012-01-04
  • 打赏
  • 举报
回复
webservice 单独访问没问题的话,看webconfig

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧