I’ve been given an asmx endpoint and good or bad, the method returns nothing:
After using the svcutil.exe to generate the Proxy and the configuration, I call the service and execute the method as:
// connect
WinnerSiteServiceSoapClient client = new WinnerSiteServiceSoapClient();
// send
client.CreateCompetitor("1", "2", "3", "4", "5", 6);
// disconnect
client.Close();
but the method CreateCompetitor, as the service documentation says, returs void, how do I assure that the method was successfully called and answered?
firing up Fiddler, I can see that I get a HTTP 200 response but, how can I get this from the proxy object?
Nutshell: no exceptions means successful request.
The proxy class abstracts away the HTTP part of sending requests to a service as you may know. This also means that you won’t find a property that corresponds to the HTTP status returned by the server (unless you tweak the generated proxy class).
When you call that void WebMethod through a proxy class and the call doesn’t fail, it means that it has been received successfully by the server. If the server throws an exception (possibly to tell you that some parameter is invalid–although it should return false or some XML that says so, but that’s a matter of design) then your call will fail with a System.ServiceModel.FaultException.
If there are network problems and the request failed to reach the server somehow then you’ll also get an exception: System.ServiceModel.EndpointNotFoundException.
Both of these exceptions are raised by the proxy class that handles the HTTP for you.