WCF service hosted in a managed Windows service connect using a WCF service application - vb.net

Thank you in advance for any advice. I have a Windows service that is hosting a WCF service through net.tcp and this is working great. I have also created a WCF service application. I am trying to add the net.tcp service reference to the service application. Then I add it to the GAC that goes ok but if I try to RegAsm the WCF service application to allow it to be called from Server.CreateObject I get the error:
Warning: Type library exporter encountered a type that derives from a
generic class and is not marked as
[ClassInterface(ClassInterfaceType.None)]. Class interfaces cannot be
exposed for such types. Consider marking the type with
[ClassInterface(ClassInterfaceType.None)] and exposing an explicit
interface as the default interface to COM using the
ComDefaultInterface attribute.
It does not work. I have tried to call it through a class library but this does not work either as the end point is not set correctly.
Any advice?

Ok Fixed this. Was a Permissions Error the iusr account did not have access to the web.config file from the WCF Service Application. So It works now. Now another problem has arised. I need to be able to call the WCF Service Application from asp classic but it does not use a web.config.

Related

How to consume wcf in .net core without adding service reference?

I want to consume a WCF service in my .NET Core application without adding service reference?
I am able to consume WCF by installing WCF connected service and adding service reference but I don't want to add any service reference.
Please refer to the follow link. It has some minors issues, but is easy to fix.
Calling Web Method Without a Service Reference
if you are using wcf service then you can expose it as a restful service. then you can simply consume it. actully i have been use it for many years and its been really useful.
here you can read more about that: REST / SOAP endpoints for a WCF service
you can create a service proxy using svcutil.exe and use the proxy class as a reference.
here is a sample:
SvcUtil.exe http://www.temperatureservice.com:8080/TemperatureService.svc /ser:DataContractSerializer /s /language:cs /out:TemperatureServiceProxy.cs /n:*,WCF.Client.Proxies.Proxy
It will generate TemperatureServiceProxy.cs file, include this file in your project and create a service client by referencing this file.

Must I add a WCF service class library in order to host a WCF Service in a Windows service?

I read about how to host Wcf Service in a Windows service. There is a guide here:
http://msdn.microsoft.com/en-us/library/ms733069.aspx
But what I did was just to create new WCF Service class and interface inside the same project of the Windows Service instead of creating a new project separatly for the Wcf service.
Is it possible to do it? because I can't add a service reference to that service from other projects in the solution. It can't find it.
OK, here is what I found.
Creating a new solution with one Windows service project with a Wcf service class and one Asp.Net folder.
Running the Windows service.
Trying to add a Service reference to the Asp.Net project.
Result: Service can't be found.
Adding a new project which contains a Wcf project to the solution.
Adding a reference to it from the Windows Service.
Trying to add a Service reference to the Asp.Net project.
Result: Service found.
Reading this link:
http://msdn.microsoft.com/en-us/library/ms731758.aspx it's done similar to what I did in the test solution, but still there is a need to write some code in the Windows Service.
In this link:
http://msdn.microsoft.com/en-us/library/ms731758.aspx
They show how to host it without creating a separate project.
So the answer to the question is no, you must not, but you have to write some code for hosting the service and can't just use the configuration file.
Note the windows service must be running so you can successfully add the reference.

Are client service contracts still autogenerated in WCF 4.0?

I have a net.tcp binding example that apparently dates back to .NET 2.0 runtime version. The client code of the WCF Net.TCP binding example has an interface marked as "System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "2.0.x.x") or so.
it also defines some Request & Response classes where the request apparently wraps the parameters of the service operation contract and the Response class wraps the result/return value. And it also defines a controller class for the service.
Now, in a WCF hosted by winform with net.tcp binding, I have found no way to autogenerate these classes myself. I wonder, is that an old way of doing things? is it required? or can I just include in the client app a reference to the DLL that contains the service?
I made some changes and now nothing works and wondered if I can just get rid of those "autogenerated" classes (or if not, HOW can I regenerate them?).
I use Visual Studio 2012 Ultimate for .NET 4.5 under Windows 7 Ultimate. My application are two winforms (client and server) that use WCF with netTCP binding.
Apparently I have to point svcutil o the base address rather than that of the service or endpoint. Then it will generate the client code and config.

Can I add ony specific WCF endpoints to a .NET 2.0 project as web references?

I'm developing a .NET 2.0 client application that needs to connect to a WCF service. I add a web reference to a basicHttpBinding WCF service that we've developed and VS creates the proxy class and the config paraphenalia which is fine. The problem is that I only want to use a small fraction of the methods that the WCF service implements and not carry around the extra implementations that the client app doesn't need.
I was thinking of creating a different basicHttpBinding endpoint and put the methods there. Is there a way for only one endpoint of a WCF service to be referenced by a .NET 2.0 project?
Regards,
Frank
When you add a web reference to a service, you always get all the service methods. It's the service (implementation) that defines the scope of what ends up in the WSDL.
The only option to limit the scope of the method your client generates would be to create a second WCF service on the backend, which only implements those few methods that you want in your client - just having a second endpoint won't really help.

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.