Generate Class Library proxy for WCF - wcf

I'm trying to write an application which gets the WCF address and generated a DLL from it.
Then I can pass it to another team (dev team) and they can use the DLL to call WCF methods without knowing anything about WCF Address and config.
Dev team knows about method names/contracts, they just don't want to add reference to WCF services they use and prefer to have a dll and just call the method from DLL.
I have heard about svcutil which generates a class and a config file. How can I write an application that executes svcutil and compiles the generated files in a dll, all programmatically.
Thanks.

Create, Host(Self Hosting, IIS hosting) and Consume WCF servcie
you need to self host service and this self host dll you can give to your other team.,..
check for the selfhosting of the wcf service.,.. also check above article which may help you to achieve your task

Related

Can I add a Service Reference with netTcpBinding in WCF?

Is it possible to add a service reference in visual studio, which generates the local proxy class to call the WCF service when using the netTcpBinding?
As I understood it, the service reference method requires a WSDL to be exposed by the service, which is only supported by the http bindings no?
Perhaps, could I add the service reference locally in development, but then switch the configuration to use nettcp at runtime in production?
The reason I am asking is because I am hosting in a windows service (server 2003, so no WAS, and can't use IIS). And we are unable to change the permissions to do the HTTP namespace reservation ... so we can't use the HTTP bindings. NetTcp works, but in this specific case the object graph we're passing back and forth involves objects generated in the service by an EDMX model ... so we can't share it in a contract assembly.
Thanks in advance!
Simply add a binding using mexTcpBinding.
Is it possible to add a service reference in visual studio,
which generates the local proxy class to call the
WCF service when using the netTcpBinding?
Yes, most definitely!
As I understood it, the service reference method requires a WSDL
to be exposed by the service, which is only supported by the http bindings no?
No, definitely not - WCF metadata (either its own specific format, or exposed as WSDL / XSD files) is definitely available for all SOAP-based calls - regardless of their transport.
Can you show us what you have, in terms of server-side config? Most likely, you're just missing a little config setting or something - if we see what you have, we might be able to pinpoint that and help you more!
All bindings are exposed though WSDL. If you add the NETTCP bindings svcutil will atuo generate the client correctly. I haven't used it in the ADD reference in VS as i have always preferred to generate the class with svcutil.

Testing WCF service with Fitnesse, should I add WebReference?

I want to use Fitnesse to do a subsytem testing of a WCF service.
Now to test a WCF service should I add the 'WebReference', and to add the webreference I require to host the service somewhere?
I believe Fitnesse as a new consumer to the service and it should add the WebReference.
For WCF, you should use "Add Service Reference" in Visual Studio, or svcutil.exe on the command line.
You can either add the reference from a running service (and then it needs to be hosted somewhere, yes), or you can extract the metadata (the WSDL that describes the service operations and the XSD that describe the message structures; again, using svcutil.exe) to files and create your client side proxy from those files.
If you only want to test the actual service implementation (without the WCF plumbing in between), you could of course also just add a normal reference to the assembly where your service implementation lives (which you hopefully isolated into a class library!), instantiate the service class, and call the methods on it. Depends on what you really want to test here...
Marc

WCF use original domain object instead of proxy generated

I have a Client website, a WCF service and a library of domain objects (.cproj).
I want the client to use my library of domain objects directly, not the proxy generated version of the domain objects. Is there a simple way of doing this?
Include a reference to the dll in your client project. Then add a Service Reference. When you add the service reference there is an option to use the types in the dll and not create them in the references.cs.
Include the library project or DLL in your client project rather than creating a service reference. You can generate the service reference to create all the necessary WCF configurations to call the service, but just don't use the generated proxy or datatypes (e.g. the code in Reference.cs) - use the types in the included DLL directly. You may need to write a client yourself, but this is simple, and can be basically copied from the generated client in a service reference.
That said, sharing the datatypes directly between the client and service sort of breaks service-oriented architecture patterns. Now both your client and service are dependent on the same DLL, rather than the client just being dependent on a service.

Windows Communication Foundation Service Library Project

Do you know if there is any way to access the wsdl file when you create a WCF service library? It seems you can get it when you create a WCF application but not the service library...
Any ideas would be appreciated.
Thanks
The only way to access the WSDL is once you host and run the service. Otherwise, you cannot access it. So, create a host (or application as you are calling it) with a mex binding, then run the service and you should be able to access the WSDL.
Once you do this, you can save the WSDL as a file or something for later reference.
You cannot access the WSDL automatically. Of course if you compile the static WSDL into the service library, as a resource, you could then access it directly.
but what is it that you are trying to accomplish?
The "Service Description" is available inside a service. It is not the WSDL itself, but rather, the in-memory model of a service description. It includes the namespaces, the element names and types - everything in a WSDL, and more.
You can get at it with System.Web.Services.Description.ServiceDescription. Typically this is done within a ServiceHost, a ServiceHostFactory, or an IEndpointBehavior.

How to connect to a WCF Service with IronPython

Has anyone done this? I've tried generating a c# proxy class and connecting through it, but I cannot figure out how to get IronPython to use the generated app.config file that defines the endpoint. It tries to connect, but I just get an error about no default endpoint. I would ideally like to make the connection using only IronPython code and not use the proxy class, if possible. The binding for the service I am trying to connect to is a NetTcpBinding if that makes any difference.
See my blog post. There are IronPython WCF service and client examples.
To use app.config, you probably must copy it to ipy.exe and rename it to ipy.exe.config but I have not tried it so I don't know whether it works or not.
Is your WCF service interface available in a shared assembly? If so, you could look at using the ChannelFactory to create your client proxy dynamically (instead of using the generated C# proxy). With that method you can supply all the details of the endpoint when you create the ChannelFactory and you won't require any configuration in your .config file.