[英]Error in asp.net webservice
My asmx webservice is like this 我的asmx网络服务就是这样
using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
using Newtonsoft.Json;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class GetRateRequestData : WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetParcelLookupData()
{
return JsonConvert.SerializeObject(dataSet, Formatting.Indented);
}
}
And I am trying to access the data in browser like this 我试图像这样在浏览器中访问数据
http://localhost:53569/services/GetRateRequestData.asmx/GetParcelLookupData/
But this throws an error like 但这会引发错误
System.InvalidOperationException: GetParcelLookupData/ Web Service method name is not valid.
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
I am new to webservices, Can any one point out what I am doing wrong here? 我是Web服务的新手,在这里有人能指出我做错了什么吗?
You can decorate your method to allow HTTP GET requests 您可以修饰方法以允许HTTP GET请求
[WebMethod]
[ScriptMethod(UseHttpGet=true)]
public string MyMethod(int myint)
{
// ... code here
}
and change your config as below 并如下更改您的配置
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
</protocols>
</webServices>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.