I've created a WCF service project. Using the standard generated example service the project generates I create a wrapper class using wsdl.exe.
However the service times out when I use the following code:
Service1 svc = new Service1();
svc.UseDefaultCredentials = true;
svc.Url = "http://localhost:16218/Service1.svc?wsdl";
string x = svc.GetData(1, true);
Wh开发者_运维百科en I invoke the same webmethod via a normal Service Reference it works fine. What am i missing?
Thanks in advance!
Well, if you want to call the service, you shouldn't be connecting to the WSDL endpoint!
svc.Url = "http://localhost:16218/Service1.svc?wsdl";
Use this code instead:
Service1 svc = new Service1();
svc.UseDefaultCredentials = true;
svc.Url = "http://localhost:16218/Service1.svc";
string x = svc.GetData(1, true);
But why would you use wsdl.exe
to create a client side bits for WCF?? Use svcutil.exe
instead! That's the right tool for the WCF job.
精彩评论