CSLA with WCF nettcpbinding - wcf

I am using CSLA.NET. It works realy nice with the wsHttpBinding. Now, I have my own Windows-Service and search the solution, that I can use this Windows-Service as the CSLA-Server and using nettcpbinding. Can someone give me a tip how to going on? Perhaps someone has a sample how I can do that.
Thank you!
Best Regards, Thomas

Basically, you need to do two things:
change your server-side configuration to include an endpoint with the netTcpBinding (this can be in addition to the existing wsHttpBinding endpoint - no problem)
add the netTcpBinding to your client's config file as well and selecting that endpoint when you connect
You should have something like this in your server side config:
<services>
<service name="YourService">
<endpoint name="something"
address=""
binding="wsHttpBinding"
contract="IYourService" />
</service>
</services>
Just add an endpoint for the netTcpBinding:
<services>
<service name="YourService">
<endpoint name="something"
address=""
binding="wsHttpBinding"
contract="IYourService" />
<endpoint name="something"
address="net.tcp://YourServer:7171/YourService"
binding="netTcpBinding"
contract="IYourService" />
</service>
</services>
Now if you're hosting in IIS, you might run into some problems - you need to configure IIS7 (Win2008 or Win2008R2 server), and in IIS6, you won't be able to host your netTcp service in IIS6 :-(
Same thing on the client side - add a second endpoint for netTcp:
<client>
<endpoint name="something"
address="http://YourServer/SomeVirtDir/YourServiceFile.svc"
binding="wsHttpBinding"
contract="IYourService" />
<endpoint name="netTcpEndpoint"
address="net.tcp://YourServer:7171/YourService"
binding="netTcpBinding"
contract="IYourService" />
</client>
and now when you create your endpoint in code, use the named endpoint:
YourServiceClient client = new YourServiceClient("netTcpEndpoint");
That should be all, really (unless CSLA requires something extra which I wouldn't know about.... I know "plain-vanilla" WCF)

Related

more than one endpoint configuration for that contract was found

I have a question about my soap services(wcf)
I implement my wcf service and all the function implement correctly at compile time
I do not have any compile time error but when i run my code I received this error message
An endpoint configuration section for contract 'test.ICore' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration
I think in soap services we need some change in web.config file
another point is that my project have multiple soap services.
may it cause a problem?
how can i solve this issue?
thank you so much
I think your problem is because of you have a multiple endpoint with the same address in your web.config file
like that
<binding name="TestSoap">
<security mode="Transport" />
</binding>
<binding name="TestSoap" />
<endpoint address="http://TestSoap/Core.svc/soap"
binding="basicHttpBinding" bindingConfiguration="Soap" contract="TestSoap.ICore"
name="TestSoap" />
<endpoint address="https://TestSoap/Core.svc/soap"
binding="basicHttpBinding" bindingConfiguration="TestSoap"
contract="TestSoap.ICore" name="TestSoap" />
you can use this example for your code.
I hople you can solve your problem
In general, an interface contract can be supported by multiple endpoints, but bindings and addresses can vary, such as this:
Server-side:
<service
name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
<endpoint address=""
binding="basicHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<endpoint address="secure"
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
</service>
Client-side:
<client>
<endpoint name="basic"
address="http://localhost/servicemodelsamples/service.svc"
binding="basicHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<endpoint name="secure"
address="http://localhost/servicemodelsamples/service.svc/secure"
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
</client>
In the call:
CalculatorClient client = new CalculatorClient("basic");
Console.WriteLine("Communicate with basic endpoint.");
client = new CalculatorClient("secure");
Console.WriteLine("Communicate with secure endpoint.");
Feel free to contact me if have any issues.

Muliple Service Behaviors to same service in WCF

Can we attach multiple service behaviors to the same service in WCF.If yes how can we do that - via config file or as attributes?
Yes, you can.
ServiceEndpoint has a Behaviors collection.
So if you create a service in C# code, you may add any behavior to this collection: standard or your one. The example of how to create custom behavior and add it to the endpoint see here. Keep in mind that you can create and add as many behaviors as you need.
If you want to add behaviors in the configuration, you will need to create Behavior configuration extension. Here is an example hot to create it and add it to the endpoint in config file.
EDIT:
Service behaviors can be added in absolute same way
Yes you can.
You need to configure your behaviors and, in service tag, configure each behavior, like this:
<service
name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
<!-- First behavior:
http://localhost/servicemodelsamples/service.svc -->
<endpoint address=""
binding="basicHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
<!-- Second behavior, with secure endpoint exposed at {base address}/secure:
http://localhost/servicemodelsamples/service.svc/secure -->
<endpoint address="secure"
binding="wsHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
</service>
The same service for ICalcular, for two different behaviors.
Read more here: https://msdn.microsoft.com/en-us/library/ms751515.aspx
Yes We can Create Multiple end points
<services>
<service name="ReportService.ReportService">
<endpoint
address="ReportService"
binding="netTcpBinding"
contract="ReportService.IReportService">
</endpoint>
<endpoint
address="ReportService"
binding="basicHttpBinding"
contract="ReportService.IReportService">
</endpoint>
</service>
</services>
we can create multiple end points like this.in client side app.config or webconfig file it show like this
<bindings>
<netTcpBinding>
<binding name="netTcpBinding_IReportService" />
</netTcpBinding>
<basicHttpBinding>
<binding name="basicHttpBinding_IReportService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="" binding="netTcpBinding"
bindingConfiguration="netTcpBinding_IReportService" contract="ServiceReference.IReportService"
name="netTcpBinding_IReportService">
</endpoint>
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding_IReportService" contract="ServiceReference.IReportService"
name="basicHttpBinding_IReportService">
</endpoint>
</client>
Then we should mention the binding name while we are referring
ServiceReference.ReportServiceClient client = new ServiceReference.ReportServiceClient(netTcpBinding_IReportService);
Now it will work with netTcpBinding

WCF EndPoints not working with IIS hosting

I have following settings
<services>
<service name="HelloWCFServiceClass.clsHelloWCFServiceClass" >
<host>
<baseAddresses>
<add baseAddress="http://localhost:6789/IISHosting/HelloWorldISSHostedService.svc"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="HelloWCFServiceContract.IHelloWCFServiceContract" />
<endpoint address="/test" binding="basicHttpBinding"
contract="HelloWCFServiceContract.IHelloWCFServiceContract"/>
</service>
</services>
I can open
http://{ServerName}:6789/HelloWorldISSHostedService.svc
But I'm getting an error
The webpage cannot be found
while trying to access through end point like this
http://{ServerName}:6789/HelloWorldISSHostedService.svc/test
You're using BasicHttpBinding - that's a SOAP binding, you cannot just use your browser to browse to that endpoint.
You'll need to use something like SoapUI to test your SOAP services.
If you want a service that's testable in your browser (by just navigating to an URL), you need to use the webHttpBinding instead (REST service)
If your service is part of an MVC project, you need to configure your routing table
http://www.asp.net/mvc/tutorials/older-versions/controllers-and-routing/asp-net-mvc-routing-overview-cs

How to Consume WCF Service in Service Reference if it has multiple Endpoint with name

I have very specific question..
If i create one WCF Service and it has multiple endpoints with the name how can i access that using browser ?
Also How can i access that in my client application via Add Service Reference ?
like my config code:
<services>
<service name="MultipleEndpoint.SampleService" behaviorConfiguration="MultipleEndpoint.SampleService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:55052/SampleService.svc"/>
</baseAddresses>
</host>
<endpoint address="/basic" binding="basicHttpBinding" contract="MultipleEndpoint.ISampleService" bindingConfiguration="basicBinding" >
</endpoint>
<endpoint address="/wsHttp" binding="wsHttpBinding" contract="MultipleEndpoint.ISampleService" bindingConfiguration="wsBinding" >
</endpoint>
<endpoint address="/webHttp" binding="webHttpBinding" contract="MultipleEndpoint.ISampleService" behaviorConfiguration="REST">
</endpoint>
</service>
</services>
Now, when i tried to access that using
http://localhost:55052/SampleService.svc/basic or
http://localhost:55052/SampleService.svc/wsHttp
it gives me page/ resource not found IE Standard Error Message...
Same time i like to know how would i add this type of url as a service reference in my client application ?
Those service addresses are different and they are not strictly needs to be brow-sable, means you can't browse a service for an endpoint like http://localhost:55052/SampleService.svc/basic. Those addresses are used to distinguish endpoints in communication.
If you see the wsdl of the service all the addresses of those endpoints are specified there.
If you create the proxy of the service through "Add Service Reference" all the endpoints are created in the configuration separately like..
<client>
<endpoint address="http://localhost:54671/Service1.svc/basic"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
<endpoint address="http://localhost:54671/Service1.svc/ws" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
name="WSHttpBinding_IService1">
</endpoint>
...
</client>
Say if you want to talk to the service using the basic http endpoint then you can create the proxy for that by passing the corresponding endpoint configuration name in the ctor.
Ex.
// this will uses the basic http endpoint.
Service1Client client = new Service1Client("BasicHttpBinding_IService1");

WCF - Beginners question on Address (of ABC)

I am new to WCF. Following is a question on WCF.
Suppose, I have a service defined as follows.
The host has two addresses. I usually click on the base address http://.... to generate proxy.
When the proxy is generated, will it have address of http alone?
How can I generate a proxy with net.tcp.
Is there any article that explains the use of net.tcp with local host and ASP.NET?
Here's my config:
<service name="XXX.RRR.Common.ServiceLayer.MySL" behaviorConfiguration="returnFaults">
<endpoint
behaviorConfiguration="LargeEndpointBehavior"
binding="netTcpBinding" bindingConfiguration="MessagingBinding"
contract="XXX.RRR.Common.ServiceLayer.IMySL" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:86/XXX/RRR/ManagerService" />
<add baseAddress="http://localhost:76/XXX/RRR/ManagerService" />
</baseAddresses>
</host>
</service>
Thanks
Lijo
What exactly is your issue here?? From your config, I see you don't have any address defined on the service endpoint - you need to supply one!
<service name="XXX.RRR.Common.ServiceLayer.MySL" behaviorConfiguration="returnFaults">
<endpoint
address=""
behaviorConfiguration="LargeEndpointBehavior"
binding="netTcpBinding" bindingConfiguration="MessagingBinding"
contract="XXX.RRR.Common.ServiceLayer.IMySL" />
When you create a client proxy against this service using the http address, then yes, the client side config will have the http endpoint as its address - something like:
<client>
<endpoint name="Default"
address="http://localhost:76/XXX/RRR/ManagerService"
binding="basicHttpBinding"
contract="XXX.RRR.Common.ServiceLayer.IMySL" />
</client>
You can simply manually add a second endpoint to the config - or use the Wcf Configuration Tool in Visual Studio to do that! - like so:
<client>
<endpoint name="Default"
address="http://localhost:76/XXX/RRR/ManagerService"
binding="basicHttpBinding"
contract="XXX.RRR.Common.ServiceLayer.IMySL" />
<endpoint name="TCP"
address="net.tcp://localhost:86/XXX/RRR/ManagerService"
binding="netTcpBinding"
contract="XXX.RRR.Common.ServiceLayer.IMySL" />
</client>
However, with the current configuration you have on the service side, you only expose a single netTcp endpoint on the server - so you won't even be able to connect to the server using HTTP to create your client proxy.....