ASMX webservice with Guid parameter

I have an asmx web service with the following method.

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

When I try to call this method, I get 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, a string, the problem disappears. Suggestions? For testing purposes, I call a service with this URL from Firefox:

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

Any suggestions?

+4
source share
2 answers

I am trying to find the official documentation, but it seems you cannot use the GUID as the input type in WebMethod, because this is not something that can be checked along the way. But I can not find the exact documentation for it.

I would most likely leave it as a string parameter, and in the first line of your method do Guid.Parse to check that it is a GUID, if not, send an exception to the user. So I saw this in other implementations that require a GUID for WebMethod.

+3
source

Have you tried this with a service using a real SOAP call?

I don’t think http GET will allow you to specify complex types.

I'm also sure that 6C388126-5787-4B63-AAFE-5BCC4EA4DF83 only represents the GUID for us people, its string for the computer - in fact, you have type mismatch, and they are not a method defined with the right arguments (since OS )

+1
source

Source: https://habr.com/ru/post/1300455/


All Articles