views:

283

answers:

2

I've got an asmx web service with the following method

    [WebMethod]
    public string LoadRegions(Guid id)
    {
        throw new NotImplementedException();
    }

When I attempt to call this method, I receive this exception:

System.InvalidOperationException: LoadRegions Web Service method 
name is not valid.
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()

If I change the parameter type from Guid to, say, string, the problem disappears. Suggestions? For testing purposes, I'm calling the service with this url from Firefox:

http://localhost:81/services/ContactService.asmx/LoadRegions
?id=6C388126-5787-4B63-AAFE-5BCC4EA4DF83

Any suggestions?

+1  A: 

I am trying to find formal documentation, but it appears that you cannot use a GUID as an input type on a WebMethod, because it is not something that can be validated on the way in. But I can't find the exact documentation on it.

I would most likely leave it as a string parameter, and have the first line of your method do a Guid.Parse to validate that it is a GUID, if not, send the user an exception. This is the way I have seen it done in other implementations that require a GUID on a WebMethod.

Mitchel Sellers
I think this is the way that I'm going to go, though it's annoying to have to go through this extra step for what is, ultimately, a very simple data type. If you find a link explicitly stating that guids aren't supported, please add it to your post.
David Lively
+1  A: 

Have you tried this using the service with an actual SOAP call?

I don't think http GET is going to allow you to specify complicated types.

I'm also pretty sure 6C388126-5787-4B63-AAFE-5BCC4EA4DF83 only represents a GUID to us humans, its a string to a computer - essentially you have a type mismatch and their isn't a method defined with the proper arguments (as far as the OS is concerned).

Ruddy