问题描述:

I have created a simple ASMX web service (void return value), which I have tested and works correctly. However, now I am attempting to create a console application which will simply consume the service.

In Visual Studio 2012, in my console application, I have right-clicked on the solution, clicked Add Service Reference, and added the service successfully. Then I added the following code to consume the service:

 static void Main(string[] args)

{

MySvc.MySvcSoapClient proxy = new MySvc.MySvcSoapClient();

proxy.CallService();

proxy.Close();

}

The above code compiles correctly, however, at runtime when it hits the proxy.CallService() line, it throws the following exception:

Server was unable to process request. ---> Object reference not set to an instance of an object.

How is it that I can launch my web service directly from a browser and it works, but when I try to consume it, I am getting an error? I haven't been able to find much relevant help online.

相关阅读:
Top