The proxy objects generated by adding a service reference are not the same objects that you define in the service contract, they are simply created in the same namespace, etc. according to customer service link. These are basically just the DTOs that you use to use the service.
If you want to have a strong dependency between objects, you cannot use the link to the service, and you need to extract the contract for a separate assembly that you can reference.
1) CibilWcfService.Contract - contains the ICIBIL interface + datacontract objects. You need to specify System.ServiceModel, System.ServiceModel.Web and System.Runtime.Serialization for the associated DataContract attributes.
2) CibilWcfService - it contains the WCF service and refers to the CibilWcfService.Contract assembly.
namespace CibilWcfService { using CibilWcfService.Contract; public class CibilService : ICIBIL {
3) CibilClient is your consumer client application, it also refers to the CibilWcfService.Contract assembly. You create a channel for a service like this, then the new CibilEnquiry () uses the same constructor as in your contract. You need to refer to System.ServiceModel for ChannelFactory.
using CibilWcfService.Contract; var cf = new ChannelFactory<ICIBIL>(); var channel = cf.CreateChannel(new EndpointAddress("http://127.0.01/CibilServiceUri")); if (channel != null) { var CibilEnquiryEnq = new CibilEnquiry(); CibilEnquiryEnq.Tuef.Version = "1111"; channel.GenerateEnquiry(CibilEnquiryEnq); }
Janne matikainen
source share