using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Runtime.InteropServices ;
namespace WebService1
{
/// <summary>
/// Service1 的摘要说明。
/// </summary>
[WebServiceAttribute(Namespace="urn:schemas-syngress-com-soap")]
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
//CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
InitializeComponent();
} #region 组件设计器生成的代码
//Web 服务设计器所必需的
private IContainer components = null;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
[System.Web.Services.WebMethod]
public string HelloWorld(string input)
{
return input;
} [System.Web.Services.WebMethod]
public double AverageScore(double[]score)
{
double sum=0;
for(int i=0;i<=score.Length;i++ )
sum+=score[i];
return sum/score.Length;
}
}
}
//我在浏览器中输入
http://localhost/WebService1/Service1.asmx/HelloWorld?input=hello
总是提示:
请求格式无法识别。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.InvalidOperationException: 请求格式无法识别。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 大家帮帮忙
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Runtime.InteropServices ;
namespace WebService1
{
/// <summary>
/// Service1 的摘要说明。
/// </summary>
[WebServiceAttribute(Namespace="urn:schemas-syngress-com-soap")]
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
//CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
InitializeComponent();
} #region 组件设计器生成的代码
//Web 服务设计器所必需的
private IContainer components = null;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
[System.Web.Services.WebMethod]
public string HelloWorld(string input)
{
return input;
} [System.Web.Services.WebMethod]
public double AverageScore(double[]score)
{
double sum=0;
for(int i=0;i<=score.Length;i++ )
sum+=score[i];
return sum/score.Length;
}
}
}
//我在浏览器中输入
http://localhost/WebService1/Service1.asmx/HelloWorld?input=hello
总是提示:
请求格式无法识别。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.InvalidOperationException: 请求格式无法识别。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 大家帮帮忙
解决方案 »
- ***************一个疑问***************
- asp.net做的网站,在本机运行正常,在服务器上部分汉字显示?号。
- 求扣除一个月中节假日及周末后剩余天数的方法!
- Visual Studio Team System 2008 Team Suite简体中文版,配哪个UML建模工具比较好。能自动生成C#代码更好。
- 求plsql语句
- 关于页面之间传输中文字的问题
- 有关网页路径的问题
- ASP.NET初学问题3个!!请教
- 用asp.net,不学script脚本(javascript, jscritp, vbscript)行吗?
- 水晶报表登陆错误
- 路过的人,请进
- 超级简单的问题,但是我就是不懂,我菜啊~~~~~~~~~~~~~~~~
先实例化这个webService,比如
Service1 service=new Service1()service.HelloWorld("你好!");
然后调用。不过我现在测试都通不过。
http://localhost/WebService1/Service1.asmx/echo?input=hello还是不好使!大哥们救救我!
就剩一下那一个方法 测试一下
还是不好使
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, String path, String pathTranslated, Boolean useAppConfig) +699
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +95
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +173