0

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?

7
  • 1
    make your method public Commented Nov 27, 2014 at 6:31
  • @SainPradeep Sorry, It was public actually Commented Nov 27, 2014 at 6:46
  • still you are getting same error. Commented Nov 27, 2014 at 6:53
  • @SainPradeep Actually It was public from the beginning , I just pasted the wrong code here. So yes, the error is same Commented Nov 27, 2014 at 7:03
  • Which framework are you using? Commented Nov 27, 2014 at 7:21

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

1 Comment

I think this is the solution too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.