简体   繁体   中英

C# WCF without service reference

I don't have any idea how to use WCF without add it to project using service reference in C#. I can't use service reference because my project haven't this option. Can someone tell my what i should to do? WSDL which I will use have methods: Login, Logout, GetData, GetDetails, GetCaptcha, CheckCaptcha.

I try this solution but I have problem with ServiceContract. I can't use this type...

 BasicHttpBinding binding = new BasicHttpBinding();
 EndpointAddress address = new EndpointAddress("www");
 ChannelFactory<ServiceContract> factory = new ChannelFactory<ServiceContract>(binding, address);
 ServiceContract channel = factory.CreateChannel();

Any ideas?

An alternative to adding a service reference is generating a proxy client using SvcUtil.exe

In Visual Studio command prompt you can generate a proxy as follows:

svcutil http://localhost/service.svc /t:code /out:ServiceProxy.cs /config:ServiceProxy.config

You can then add the generated proxy class and configuration to your project and start using the client.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM