Reputation: 1073
I have build a test WCF Service Service1.svc I have added service reference of the service to my Winform. Its working good and i can easily consume the WCF service in winform. But i got a major problem :
App.config :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://svc.phed.net/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
You have created a service. To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
Upvotes: 0
Views: 718
Reputation: 3757
If you don't have the service configuration, you can create a proxy manually.
Here is an example:
var binding = new BasicHttpBinding();
var endpoint = new EndpointAddress("YourEndPoint");
var channelFactory = new ChannelFactory<YourInterface>(binding, endpoint);
YourInterface client = null;
client = channelFactory.CreateChannel();
client.YourOperation();
In above example, I've used the BasicHttpBinding. If you're using another binding, just use the right class, for instance a NetTcpBinding.
If you handle your service in a try/catch block you can be able to handle this error and throw a most friendly message to your client.
Hope it helps.
Upvotes: 1