开发者

ASMX webservice with Guid parameter

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

    [WebMethod]
    public string LoadRegions(Guid id)
    {
        throw new NotImplemented开发者_JAVA技巧Exception();
    }

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?


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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜