Depends on how your service is called. When you created the service reference, you gave it a namespace name - in that namespace, there should be a class called (yourservicename)Client - instantiante one of those and get going.
You should find those files under the Service Reference - if you click on the "show all files" button in the Solution Explorer, you'll start seeing a ton of files under your service reference - one in particular should be Reference.cs
. Those classes are defined in that file - you can check it out, it's a regular C# file.
Update: If you create your proxy using svcutil.exe
, depending on your options used with svcutil
, you should also get a .cs file that contains the classes needed.
svcutil http://yourserver/yourservice
would create a file called (your WSDL name).cs
and an output.config
in that directory where you run this command.
You can also specify a file name for the C# file:
svcutil http://yourserver/yourservice /out:MyService.cs
and then your file is called MyService.cs
.
SvcUtil has a ton of options - can't explain them all to you, play around with them, read up on the MSDN docs for it.
Again, one of them will be called (your service name)Client
. Include that *.cs file in your project, check the namespace, create an instance of the .....Client
class and use it to call the WCF service.
Example:
Grab info from URL
svcutil http://www.ecubicle.net/iptocountry.asmx?wsdl /out:IP2CountryClient.cs
Include the resulting IP2CountryClient.cs
in your project; by default, the classes in that file are in no particular namespace, so they're globally visible
Instantiate the client class iptocountrySoapClient
iptocountrySoapClient client = new iptocountrySoapClient();
Call methods - e.g. this one here:
string result = client.FindCountryAsString("82.82.82.82");