Configuration binding extension could not be found - wcf

I am trying to get a WCF webservice running which will participate in distributed transactions. I keep getting the following error message...
Configuration binding extension 'system.serviceModel/bindings/myBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly
Here is the web.config
<system.serviceModel>
<services>
<service name = "DistServiceX">
<endpoint
address=""
binding="myBinding"
contract="IDistService"
/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding
name="myBinding"
transactionFlow="true"
/>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
Can anyone see what is wrong with this? It's driving me crazy!
Thanks
Pete

You are referring to a custom binding here:
<service name = "DistServiceX">
<endpoint
address=""
binding="myBinding"
contract="IDistService" />
However, there is no custom binding called myBinding anywhere in your config.
I assume you really want to refer to a wsHttpBinding and the myBinding binding configuration that you specified in your config file. Furthermore: the name of the service must match the fully qualified name of the class that implements the service - including namespace (and also: the name of the contract being implemented by that service and exposed on a given endpoint must include any namespaces):
<service name="YourNamespace.DistServiceX">
<endpoint
address=""
binding="wsHttpBinding"
bindingConfiguration="myBinding"
contract="YourNamespace.IDistService" />

Related

WCF - convert HTTP to Named Pipe

Guys I've been looking at a ton of blogs, SO posts this week and I am still unsure as to how I convert my WCF service from HTTP bindings to using Named Pipes.
I think there are different ways to do it, but I am using the web.configs and using a service reference in my code.
Rather than detail everything here I've tried, can I ask this question?
What are the steps I need to take to go from HTTP Binding to Named Pipes?
Do I need this MEX thing I see mentioned in (some) blogs/SO posts?
I know I need to set IIS to enabled protocols: net.pipe... and that IIS Express doesn't support this (that took an afternoon!)
Some relevant code, what I have right now:
in IEmployeeData:
namespace Mobile.ServiceLayer {
[ServiceContract]
public interface IEmployeeData
{ ... }
Calling the WCF service:
string endpointConfigName = "BasicHttpBinding_IEmployeeData";
EmployeeSvcRef.EmployeeDataClient edc = new EmployeeSvcRef.EmployeeDataClient(endpointConfigName);
EmployeeSvcRef.EmployeeListResponse emp = edc.EmployeeList();
WCF service web.config:
<services>
<service name="Mobile.ServiceLayer.EmployeeData">
<host>
<baseAddresses>
<add baseAddress="http://localhost:62734/EmployeeData" />
</baseAddresses>
</host>
</service>
...
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
client web.config:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IEmployeeData" />
...
<client>
<endpoint address="http://localhost:62734/EmployeeData.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IEmployeeData" contract="EmployeeSvcRef.IEmployeeData"
name="BasicHttpBinding_IEmployeeData" />
Like I said I've looked at SO posts and blogs but there's always a piece of the puzzle missing it seems!
EDIT: Client web.config after wizard:
<endpoint address="net.pipe://localhost/EmployeeData.svc/" binding="netNamedPipeBinding"
bindingConfiguration="NewBinding0" contract="IEmployeeData"
name="" kind="" endpointConfiguration="">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
Ok this is what I did. You may find it easier to use the built-in tools mentioned in Max's comments. Right click on a web.config and choose Edit WCF Configuration. Get the WCF service done first and, providing the endpoints are set up, running this on the client (right click it's web.config) will present you with a wizard.
SERVER WEB.CONFIG
Service name is the fully-qualified name of the interface e.g. Mobile.ServiceLayer.IEmployeeData
The base address changes to
net.pipe://localhost/EmployeeData.svc
. Notice the port number is removed and the .svc is present(!)
Create an endpoint, the contract being your interface and binding of type netNamedPipeBinding.
Add a second endpoint for MEX which is MetadataEXchange.
Set ServiceMetaData httpGetEnabled to false.
<system.serviceModel>
<services>
<service name="Mobile.ServiceLayer.IEmployeeData">
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/EmployeeData.svc" />
</baseAddresses>
</host>
<!-- NetPipe -->
<endpoint
address=""
binding="netNamedPipeBinding"
contract="IEmployeeData" name="MyNetPipe" />
<!-- Mex (Net.Tcp / Net.Pipe ) -->
<endpoint name="EmployeeDataNetPipeMex" address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
CLIENT WEB.CONFIG
Remove the binding entry from 'basicHttpBinding'
Add the section with an entry named NetNamedPipeBinding_IEmployeeData
Inside 'client' add an endpoint with the address
net.pipe://localhost/EmployeeData.svc
the contract being the 'referencename'.'interface'
<bindings>
<basicHttpBinding>
</basicHttpBinding>
<netNamedPipeBinding>
<binding name="NetNamedPipeBinding_IEmployeeData" />
</netNamedPipeBinding>
</bindings>
<client>
<endpoint address="net.pipe://localhost/EmployeeData.svc" binding="netNamedPipeBinding"
bindingConfiguration="NetNamedPipeBinding_IEmployeeData" contract="EmployeeSvcRef.IEmployeeData"
name="NetNamedPipeBinding_IEmployeeData" />
</client>

how to configure wcf endpoints?

<system.serviceModel>
<services>
<service
name="myClass.IService1" behaviorConfiguration="myService">
<endpoint
name="ep1"
address="http://localhost:57582/Service1.svc"
contract="IService1"
binding="basicHttpBinding"
/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myService">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
but still i am getting the following error::
Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.
your service name IService1 - this looks like it might in fact be
the contract. If you are using the normal templates then remove the
I from IService1
If you are IIS hosting you can remove the address as the location of the .svc file is automatically the address.
The contract needs to be fully qualified including the namespace of the contract interface
with this in place your metadata should be served from <.svc file location>?wsdl

Can't host tcp based wcf service on IIS, Cannot obtain Metadata from net.tcp://localhost/TestApp2/MyService error pops up

I have a simple test purpose WCF service. I'm trying to host it under IIS 7.5 ( Windows 7 ) but no luck so far. I'm getting error
Cannot obtain Metadata from net.tcp://localhost/TestApp2/MyService
I have a web site TestApp2 under Default Web Site, I enabled tcp on Default Web Site and TestApp2. Here is my web.config file, while I realize that this error simply states that I didn't have endpoint for metadata exchange, I can't see what's the problem because I included endpoint for metadata exchange.
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="MyService">
<endpoint address="net.tcp://localhost/TestApp2/MyService"
binding="netTcpBinding"
bindingConfiguration="PortSharingBinding"
contract="II7WcfService.IService1" />
<endpoint address="MEX"
binding="mexTcpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost/TestApp2/MyService" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="PortSharingBinding" portSharingEnabled="true">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="False" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
Thanks.
My guess is your service isn't actually called MyService but rather it is in a namespace. This means your declared endpoints are not getting picked up, and the default ones (which doesn't include IMetadataExchange) are being used instead.
Add the name of your namespace to the attribute in the config and it should work.

basicHttpBinding security mode not successfully inferred by wcf test client

I have a WCF Service programmed in VB.NET that is exhibiting strange behavior. The web.config has the following xml:
<system.serviceModel>
<services>
<service behaviorConfiguration="CentricBasicHttpBehavior" name="OnbaseService">
<endpoint binding="basicHttpBinding" bindingConfiguration="CentRicBasicHttpServerBinding" contract="IOnbaseService">
<identity>
<servicePrincipalName value="HTTP/JFOLKENDT7E" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CentricBasicHttpBehavior">
<serviceAuthorization impersonateCallerForAllOperations="true" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
<serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100" maxConcurrentInstances="100" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="CentRicBasicHttpServerBinding" maxReceivedMessageSize="5000000">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
When I configure the service in wcf test client, both the Binding Mode and TransportClientCredentialType are coming across as "None". I expected for them to be "TransportCredentialOnly" and "Windows" respectively.
Can someone please share with me how WCF Test Client infers the binding configuration, and how I should go about correcting this issue? The end result is that within the source code of the service, the WindowsIdentity isn't impersonating the user like I expected.
Thanks,
Jason
I work with Jason and we looked at this together. The service configuration needed the name and contact properties to match the fully qualified service class name and fully qualified contact interface name. Otherwise, we were getting the fun new .Net 4.0 defualt bindings for a default service.
In my own experience with WCF, I had modified session Timeouts and connection Timeout settings in the config file but WCF Test Client was not respecting those settings. Seems like WCF Test client just takes up the default values for communicating with WCF services. Hence I test my WCF services using my own custom WCF Test Clients by generating app.config and proxy. cs through svcutil.exe .

WCF MetaData not working

I have tried several times to have my WCF service expose MetaData. Instead, I keep keeping the exception:
The contract name 'IMetadataExchange'
could not be found in the list of
contracts implemented by the service
SecurityBroker. Add a ServiceMetadataBehavior to the
configuration file or to the
ServiceHost directly to enable support
for this contract.
... when manually browsing to the service using IE.
(I am presuming this is the same reason why my client application isn't able to generate a service reference. Baby steps and all)
And yet my web.config looks okay:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<endpointBehaviors>
<behavior name="webHttpEnablingBehaviour">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="webHttpEnablingBehaviour">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="IWW.MIGTurbo2.WCF.Security.SecurityBroker">
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration="default"
contract="IWW.MIGTurbo2.WCF.Security.ISecurityBroker"
behaviorConfiguration="webHttpEnablingBehaviour">
</endpoint>
</service>
</services>
<client />
<bindings>
<webHttpBinding>
<binding name="default" />
</webHttpBinding>
</bindings>
</system.serviceModel>
So I have my IMetadataExchange contract defined with mex fine, and hooked up, as far as I can see. Have I missed something daft?
Edit
My Service definition is shown below, if this is useful:
<%# ServiceHost Language="C#" Debug="true" Service="IWW.MIGTurbo2.WCF.Security.SecurityBroker" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>
Your config file has the behaviorConfiguration attribute on the "endpoint" element, but you also need it on the "service" element.
I am using NetTcpBinding for all. In my case I was having the same issue and resolved it by adding:
(a) a behaviorConfiguration="" to the mex endpoint
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" behaviourConfiguration="" />
(b) a behaviorConfiguration="mex" to the service definition:
<services>
<service name="AcmeService" behaviorConfiguration="mex">
(c) The behaviour entry
<behaviors>
<serviceBehaviors>
<behaviour name="mex">
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>