My asmx webservice is like this
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?
You can decorate your method to allow HTTP GET requests
[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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.