Reputation: 297
I have a small question: Can we consume a web-service reference like a sample dll? I mean something like following: 1. Add reference to assembly in the references 2. add namespace to using (using mywebservice) 3. use it in code like:
var service = new mywebservice.Service1();
var result = service.GetSomething()?
Why I'm asking? It's because of I tried but I get a "strange" error: Cannot load assembly "MyService.dll version, and so on". Thanks in advance!
Upvotes: 0
Views: 1412
Reputation: 151604
Yes, you can perfectly create a WCF Service Reference (aka a client proxy) and stick that in an assembly purely meant to serve as a centralized, shareable client proxy. This way, when adding a service operation, you don't have to update the reference in all projects that consume your service, but just update the reference in the assembly.
Please note that if the service reference was configured to reuses types found in assemblies referenced by the client proxy project, you also need to add references to those assemblies to the project using your client proxy assembly.
Cannot load assembly "MyService.dll version, and so on"
That is a symptom, usually explained by errors surrounding that error. It could prove really useful if you showed all relevant warnings and errors in your question.
You probably just need to add a reference to System.ServiceModel
to the project using your client proxy assembly, are missing other assembly references or your service project fails to build so it acutally can't find the DLL.
Upvotes: 0
Reputation: 6619
You can create a service reference
http://msdn.microsoft.com/en-us/library/bb628649.aspx
What you should note is what the name space is that you put your proxy under. It's the namespace that decide the what you should type instead of "mywebservice"
Upvotes: 1