First of all to generate proxy class we need to have our service up and running. So before using this utility make sure that your service is running without any issue.
After verifying the service status go to Visual Studio Command Prompt and run the following command.
svcutil http://localhost/MyService/ClassName.svc /Language=c#
/t:Code /out:ClassNameProxy.cs /config:ClassNameProxy.config
In above command you should replace the service URL ( http://localhost/MyService/Service1.svc
) with the URL of your service.
Since my services is developed in c#.net so I choose to generate the proxies in the same language by using /Language=c# flag.
/t:code will specify that the out put should be generated as code.
/out:ClassNameProxy.cs /config:ClassNameProxy.config parameters will tell the utility to name the files as specified in these parameter values.
After you run the command, tool will generate the output file and config file.
After that just include the ClassNameProxy.cs file into your project and open the ClassNameProxy.config file and copy the entries to your web.config file.
You may also need to update the ClassNameProxy.vb file and update the namespace as per the one that you are using in your project. After that you can easily reference the service in your code and call the operations.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…