NetNamedPipeBinding create an issue when service is restarted - wcf

We are using WCF service with NetNamedPipeBinding binding. It works without any problem.But some time when we replace service's bin in IIS or restart the service then client can not connect with service. During this error If we change the binding from NetNamedPipeBinding to BasicHttpBinding in client side then work perfectly.
Client does not receive the response from the service. So how we can overcome from this issue and just want to know what is the actual issue with NetNamedPipeBinding?
if there is an any better replacement of NetNamedPipeBinding.
Update:
Service side configuration
<services>
<service behaviorConfiguration="ServicesBehavior" name="WcfServices.Service1">
<endpoint address="soap" behaviorConfiguration="FlattenWsdlEndpointBehavior" binding="basicHttpBinding" contract="WcfServices.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="json" behaviorConfiguration="webHttpBehavior" binding="webHttpBinding" contract="WcfServices.IService1" />
<endpoint address="NamedPipe" binding="netNamedPipeBinding" contract="WcfServices.IService1" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
Client side configuration
<client>
<endpoint address="http://someAddress/WcfServices/Service1.svc/soap" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" contract="WcfServices.IService1" name="BasicHttpBinding_IService1" />
<endpoint address="net.pipe://localhost/WcfServices/Service1.svc/NamedPipe" binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IService1" contract="WcfServices.IService1" name="NetNamedPipeBinding_IService1" />
</client>
Thanks in advance.
If someone can help me on this.

Related

SoapUI wsdl wcf net.tcp missing importer

Nn generall I have serving hosting on tcp and I can't parse my wsdl with SoapUI, while it works with wcfTestClient.
SoapUI gives me error:
Missing importer for...
Missing portType for binding..
Unfortunally I need to add headers which I heard is immposible for wcfTestClient.
And my service configuration
<service name=".." behaviorConfiguration="...">
<endpoint binding="netTcpBinding" bindingNamespace="http://.." bindingConfiguration="SecureNetTcpBinding" contract="..." address="" />
<endpoint address="mex" bindingNamespace="http://.." binding="netTcpBinding" bindingConfiguration="SecureNetTcpBindingMex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:50002...svc" />
</baseAddresses>
</host>
</service>
<binding name="SecureNetTcpBindingMex" maxConnections="400" listenBacklog="400">
<security mode="None">
</security>
</binding>
Is it possible to parse wcf net.tcp with SoapUI ? If not what options do I have ?
Just add the following endpoint:
<endpoint address="soap" binding="basicHttpBinding" contract="...">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
Then consume into SoapUI from http://localhost:50002...svc/soap

Are different mexHttpBinding for different endpoints possible in WCF?

I have 3 service contract interfaces in my WCF library like this:
public interface ServiceContract1{}
public interface ServiceContract2{}
public interface ServiceContract3 : ServiceContract1, ServiceContract2 {}
Also I have a service which implements ServiceContract3. I can have different endpoints by setting different contracts for each like this:
<endpoint address="net.tcp://localhost:5556/ServiceContract1"
binding="netTcpBinding" name="netTcpBinding1"
contract="WcfServiceLibrary.IServiceContract1">
<endpoint address="net.tcp://localhost:5556/ServiceContract2"
binding="netTcpBinding" name="netTcpBinding2"
contract="WcfServiceLibrary.IServiceContract2">
These endpoints seem to work very well but there is only one mexHttpBinding endpoint automatically generated. Thus, although a client needs to use one of the endpoints, it will have whole classes after adding Service Reference.
Can i have different mexHttpBinding endpoints for different contracts? Is there any approach can i follow? Thanks for your help.
Edit #1: ServiceModel configuration
<system.serviceModel>
<services>
<service name="WcfServiceLibrary.Service">
<endpoint address="net.tcp://localhost:5556/Service1"
binding="netTcpBinding" name="netTcpBinding"
contract="WcfServiceLibrary.IServiceContract1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:5556/Service2"
binding="netTcpBinding" name="netTcpBinding"
contract="WcfServiceLibrary.IServiceContract2">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
name="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:5555/ConsoleHost" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
I have only one service hosted in my console application:
ServiceHost host = new ServiceHost(typeof(WcfServiceLibrary.Service));
host.Faulted += new EventHandler(Host_Faulted);
// Start listening for messages
host.Open();

WCF how to bind multiple service contracts?

First off I'll apologise as this is probably a duplicate but everything I read seems to be either incomplete or confusing as I'm very new to WCF.
I basically am looking to deploy a WCF service in IIS with 2 endpoints accessible and have been going around in circles all day :(
I have a service library WCF dll with the following structure
App.config
TestSvc1.cs
ITestSvc1.cs
TestSvc2.cs
ITestSvc2.cs
This works fine in the VS WCF test client and now im deploying to IIS so I created a WCF Service Application and referenced the dll. This project has the following structure
Service1.svc
Web.config
Service1.svc contains this
<%# ServiceHost Language="C#" Debug="true"
Service="WCFServices.TestServices.ITestSvc1" CodeBehind="Service1.svc.cs" %>
and my web.config has the following
<services>
<service name="WCFServices.TestServices.TestSvc2">
<endpoint
address=""
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc2">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/wcf2/TestServices/TestSvc2/" />
</baseAddresses>
</host>
</service>
<service name="WCFServices.TestServices.TestSvc1">
<endpoint
address=""
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc1"
listenUri="http://localhost:8080/wcf2/service1.svc">
<identity>
<dns value="" />
</identity>
</endpoint>
<endpoint
address=""
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc2"
listenUri="http://localhost:8080/wcf2/service1.svc">
<identity>
<dns value="" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/wcf2/TestServices/TestSvc1/" />
</baseAddresses>
</host>
</service>
</services>
Any help would be greatly appreciated. As you can see I've tried to add an additional endpoint in the web.config but this doesn't work, I get an error saying that TestSvc2 calls can't be found in TestSvc1 which I guess relates to the entry in Service1.svc
I also read about creating a class that inherits these interfaces but I am not sure exactly how to implement it based on what I have above. Do I need to modify the Service1.svc?
public interface MultipleSvc : ITestSvc1, ITestSvc2
{
// What exactly do I put here? I have no idea, do I leave it blank? This didn't work for me
}
Any help would be greatly appreciated guys thanks :)
Golden rule: one .svc = one service (or more specifically: one service implementation class)
So if you do have two separate, distinct services (in classes WCFServices.TestServices.TestSvc1 and WCFServices.TestServices.TestSvc2), then you need two .svc files (one each, for each service)
What you could do is have one service implementation class that implements both service contracts:
public class MultipleServices : ITestSvc1, ITestSvc2
{
// implement the service logic here, for both contracts
}
In that case, one svc file will be enough (the .svc file is per implementation class and can host multiple service contracts). But then you'd need to change your config, too - since you really only have one service class (therefore: one <service> tag) and multiple contracts hosted inside it:
<services>
<service name="WCFServices.TestServices.MultipleServices">
<endpoint
address="Service1"
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc1">
<identity>
<dns value="" />
</identity>
</endpoint>
<endpoint
address="Service2"
binding="wsHttpBinding" bindingConfiguration="LargeSizeMessages"
contract="WCFServices.TestServices.ITestSvc2">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
Also: since you seem to be hosting your WCF service in IIS, there's no point in defining any <baseAddress> values - the "base" address of your service is the location (URI) where the *.svc file lives.
You do'nt need two svc file. Choose ServiceReference1.Service1Client or ServiceReference1.Service2Client.

What are the reasons that cause ServiceActivationException?

I have a service which is hosted in Azure environment. i am consuming that service using a console application. While doing so, i get exception:
"The requested service,
'http://xxxx-d.yyyy.be/Services/zzzzInService.svc' could not be
activated. See the server's diagnostic trace logs for more
information."
Can anyone help me to find what i am missing ?
The service is defined like this -
<service name="xxxx.AppServer.Host.Services.yyyyy.zzzzPlugInService"
behaviorConfiguration="MetadataBehavior" xdt:Locator="XPath(//service[#name='xxxx.AppServer.Host.Services.yyyy.zzzzPlugInService'])" xdt:Transform="Replace">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="xxxx.Shared.IntegrationServices.yyyy.IzzzzPlugInService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpsBinding" contract="xxxx.Shared.IntegrationServices.yyyy.IzzzzPlugInService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
When i Use the link http://xxxx-d.yyyy.be/Services/zzzzInService.svc in browser i get these messsage -
The binding at system.serviceModel/bindings/basicHttpBinding does not
have a configured binding named 'basicHttpBinding'. This is an invalid
value for bindingConfiguration.
source :
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="xxxx.Shared.IntegrationServices.zzzzz.IzzzzPlugInService">
The error says that you don't have a binding configuration for "basicHttpBinding" named "basicHttpBinding". Since you didn't post your complete config, and the error message says that, I'll assume that this is the case.
The config below (under <system.serviceModel>) has two binding definitions under <basicHttpBinding>, one for each binding configuration you have in your endpoint declarations. You should have something similar in your config as well.
<services>
<service name="xxxx.AppServer.Host.Services.yyyyy.zzzzPlugInService"
behaviorConfiguration="MetadataBehavior"
xdt:Locator="XPath(//service[#name='xxxx.AppServer.Host.Services.yyyy.zzzzPlugInService'])"
xdt:Transform="Replace">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding"
contract="xxxx.Shared.IntegrationServices.yyyy.IzzzzPlugInService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="basicHttpsBinding"
contract="xxxx.Shared.IntegrationServices.yyyy.IzzzzPlugInService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" />
<binding name="basicHttpsBinding">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
One of the other reasons can be if you have a duplicate or overload methods in your svc.cs file

How to configure basicHttpBinding for WCF service

I have a WCF service that I'm trying to get to work with wcf, old soap and plain xml. The service is called TestService.svc and the configuration looks like this:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="TestServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="poxBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="TestServiceBehavior" name="TestService">
<endpoint address="" binding="wsHttpBinding" contract="ITestService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint address="soap" binding="basicHttpBinding" contract="ITestService"/>
<endpoint address="xml" binding="webHttpBinding" behaviorConfiguration="poxBehavior" contract="ITestService"/>
</service>
</services>
</system.serviceModel>
I got this code from this other question:
REST / SOAP endpoints for a WCF service
Now, the XML webHttpBinding seems to work well, but the wsHttpBinding and basicHttpBinding does not work very well.
I can browser to the service using:
http://localhost:8295/WCFTest/TestService.svc
I can also use that endpoint to add a service reference in an asp.net web site project and attempt to consume the service, but when I create the client:
TestService.TestServiceClient mytest = new TestService.TestServiceClient();
It says to specify an endpoint due to multiple endpoints. I guess due to having both wsHttp and basicHttp? How do I specify the endpoint here?
Next I try to consume the basicHttpBinding endpoint by adding a Web Reference (not service reference) to a .net 2.0 web site. At this point I'm not able to add the reference and receive an error 400.
So next I remove the wsHttp binding and am able to add the web reference and consume the service via a .net 2.0 client.
How do I configure it so that I can use wsHttpBinding for clients that can consume normal WCF services, basicHttpBinding for clients that can only consume older non-WCF SOAP requests and still have webHttpBinding available for clients that want to consume plain xml?
The person who posted this link (http://www.codemeit.com/wcf/wcf-restful-pox-json-and-soap-coexist.html) appears to be correct. But since this question remains unanswered, I'll elaborate a bit.
If you haven't tried it, I will mention first that nowhere in your configuration do you specify an actual address for the client service to connect to.
<service behaviorConfiguration="TestServiceBehavior" name="TestService">
<endpoint address="" binding="wsHttpBinding" contract="ITestService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint address="soap" binding="basicHttpBinding" contract="ITestService"/>
<endpoint address="xml" binding="webHttpBinding" behaviorConfiguration="poxBehavior" contract="ITestService"/>
</service>
Your first endpoint has
<endpoint address="" binding="wsHttpBinding" contract="ITestService">
Based on documentation on MSDN (found here) and the link above, it appears that you are missing this in your service configuration
<host>
<baseAddresses>
<!-- note, choose an available port-->
<add baseAddress="http://localhost:8295/WCFTest/TestService" />
</baseAddresses>
</host>
Adding that would make your service configuration look like this
<service behaviorConfiguration="TestServiceBehavior" name="TestService">
<host>
<baseAddresses>
<!-- note, choose an available port-->
<add baseAddress="http://localhost:81/TestService" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="ITestService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint address="soap" binding="basicHttpBinding" contract="ITestService"/>
<endpoint address="xml" binding="webHttpBinding" behaviorConfiguration="poxBehavior" contract="ITestService"/>
</service>
Adding that section will provide the address to use, while the specific endpoints will then use addresses relative to the base address provided.