netnamedpipebinding Failed to add a service. Service metadata may not be accessible - wcf

<services>
<service name="WcfServiceApplication.WallService" behaviorConfiguration="mex" >
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost:10042/"/>
</baseAddresses>
</host>
<endpoint address="WallService.svc"
binding="netNamedPipeBinding" bindingConfiguration="basic" name="Basic"
contract="WcfServiceApplication.IWallService"></endpoint>
<endpoint address="mex"
binding="mexNamedPipeBinding"
contract="IMetadataExchange"></endpoint>
</service>
</services>
<bindings>
<netNamedPipeBinding>
<binding name="basic"></binding>
</netNamedPipeBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="mex">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

I have found the solution by troubleshooting and have resolved it.
Service should be hosted in a process and then be called.

Related

wsdl not showing XML-WCF

When calling service url https://example.com/TestService.svc I am getting the below 2 URLs but when I am trying to click on WSDL then it is not working.
WSDL URLs
http://example.com/TestService.svc?wsdl -- NOT WORKING
http://example.com/TestService.svc?singleWsdl -- NOT WORKING
Manually change http to https
https://example.com/TestService.svc?wsdl -- WORKING
https://example.com/TestService.svc?singleWsdl -- WORKING
Client Config
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</client>
<behaviors>
<serviceBehaviors>
<clear/>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" />
Main Service Config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<clear />
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0">
<serviceActivations>
<clear />
<add factory="DataServicesHost.UnityServiceHostFactory" relativeAddress="TestService.svc" service="TestService.Service" />
</serviceActivations>
</serviceHostingEnvironment>
Service Consuming
var customHeader = new MessageHeader<Security>(security);
var tempHeader = customHeader.GetUntypedHeader("Security", "http://tempuri.org/");
var client = new ServiceClient();
using (var scope = new OperationContextScope(client.InnerChannel))
{
OperationContext.Current.OutgoingMessageHeaders.Add(tempHeader);
objDataRequest = client.DataRequest("test");
}
From the above configuration, we can infer that it belongs to the client-side. However, the WSDL feature of the WCF service is set up on the server-side. It is controlled by the ServiceMetadata section.
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
Therefore, if we want to have the HTTP protocol of WSDL feature working, we need to enable it on the server-side and apply the service behavior in the service section(the endpoint should be within the service section instead of client section).
<system.serviceModel>
<services>
<service name="WcfService3.Service1" behaviorConfiguration="sb">
<endpoint address="" binding="basicHttpBinding" contract="WcfService3.IService1"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="sb">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
Feel free to let me know if there is anything I can help with.

WCF- 1 service, multiple endpoints and multiple behaviours?

I have 1 service and multiple endpoints as shown below. I want to have a general behaviour and overwrite my wshttpbinding with another behaviour but when I try that I receive error tells me
Parser Error Message: There is no endpoint behavior named 'CredentialValidator'.
what am I doing wrong?
<services>
<service name="myservice.Service.myserviceService" behaviorConfiguration="myserviceBehaviour">
<host>
<baseAddresses>
<add baseAddress="https://localhost:44300/myService.svc"/>
<!--<add baseAddress="http://localhost:54941/myService.svc"/>-->
<!--<add baseAddress="http://myservicewcf.myurl-staging.com/myService.svc"/>-->
<add baseAddress="https://myservice.myurl-staging.com/myService.svc"/>
<add baseAddress="https://myservice.production.com/myService.svc"/>
<!--<add baseAddress="https://myservicetest.myurl-staging.com/myService.svc"/>-->
</baseAddresses>
</host>
<endpoint name="myserviceSoap12Endpoint" address="soap12" binding="customBinding" bindingConfiguration="soap12selfBinding" contract="myservice.Service.ImyserviceService" behaviorConfiguration="CredentialValidator" />
<endpoint name="myserviceWSHttpEndpoint" address="ws" binding="wsHttpBinding" bindingConfiguration="myserviceWSHttpBinding" contract="myservice.Service.ImyserviceService"/>
<endpoint name="myserviceBasicHttpEndpoint" address="" binding="basicHttpBinding" bindingConfiguration="myserviceBasicHttpBinding" contract="myservice.Service.ImyserviceService"/>
<!--<endpoint name="myserviceBasicHttpEndpoint2" address="" binding="basicHttpBinding" bindingConfiguration="myserviceBasicHttpBinding" contract="myservice.Service.ImyserviceService2"/>-->
<endpoint name="myserviceMexEndpointHttps" address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name ="CredentialValidator">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug
includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="myservice.Service.CustomUserNameValidator, myservice"/>
</serviceCredentials>
</behavior>
<behavior name="myserviceBehaviour">
<useRequestHeadersForMetadataAddress/>
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
Try putting your CredentialValidatorbehavior in <endpointBehaviors> tags instead of <serviceBehaviors>.
Because the exception message clearly states that there is not any endpointBehavior with that name. So give it one! Like this:
<behaviors>
**<endpointBehaviors>**
<behavior name ="CredentialValidator">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
**</endpointBehaviors>**
<serviceBehaviors>
<behavior name="myserviceBehaviour">
<useRequestHeadersForMetadataAddress/>
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>

WCF application Endpoint not found

So the problem I could guess I'm facing is the configuration of web config. Let me tell what I'm doing,
Created WCF library
created on WCF application and refer the library DLL.
After that when I run the WCF application it gives me the error endpoint not found.
<system.serviceModel>
<services>
<service name="Boost.Web.CARD.services.CardServiceLibrary.CardService"
behaviorConfiguration="HostBehavior">
<endpoint
address=""
binding="webHttpBinding" bindingConfiguration="CardCustomBinding"
contract="Boost.Web.CARD.services.CardServiceLibrary.ICardService"/>
</service>
</services>
<diagnostics wmiProviderEnabled="true">
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"/>
</diagnostics>
<bindings>
<webHttpBinding>
<binding name="CardCustomBinding" allowCookies="true"
maxBufferSize="20000000" maxBufferPoolSize="20000000"
maxReceivedMessageSize="20000000">
<readerQuotas maxDepth="32" maxStringContentLength="20000000"
maxArrayLength="20000000"/>
<security mode="None"/>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="HostBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
I just want to test it on my local machine not on the server. I am adding my WCF library config part as well that might also help in sorting out the issue.
<system.serviceModel>
<services>
<service behaviorConfiguration="Boost.Web.CARD.services.CardServiceLibrary.Service1Behavior" name="Boost.Web.CARD.services.CardServiceLibrary.CardService">
<endpoint address="" behaviorConfiguration="Web" binding="webHttpBinding" contract="Boost.Web.CARD.services.CardServiceLibrary.ICardService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/service/1.0/rest" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="Web">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Boost.Web.CARD.services.CardServiceLibrary.Service1Behavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>

Can't get Metadata Publishing for my WCF webHttpBinding Service

I keep getting the page when I browse to my svc file that metadata publishing is not turned on but I have done everything for it. Here's my web.config. What am I doing wrong?
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="AlphaFrontEndSiteASP.TestsServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="AlphaFrontEndSiteASP.Services.TestsService">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="AlphaFrontEndSiteASP.Services.TestsService" behaviorConfiguration="MetadataBehavior">
<endpoint address="" behaviorConfiguration="AlphaFrontEndSiteASP.TestsServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="AlphaFrontEndSiteASP.Services.TestsService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
</system.serviceModel>

ServiceActivationException because of bindingConfiguration attribute

I want to be able to access the service using both http and https
On endpoint at address "secure", If I include the bindingConfiguration attribute, I get a ServiceActivationException.
But if I remove the bindingConfiguration="webBindingSecure", all works well. What is the problem with the bindingConfiguration?
<system.serviceModel>
<services>
<service name="OperatorApp.Api" behaviorConfiguration="ServiceBehaviour">
<endpoint address="secure" binding="webHttpBinding" **bindingConfiguration="webBindingSecure"** contract="OperatorApp.IApi" behaviorConfiguration="ssl" />
<endpoint address="normal" binding="webHttpBinding" contract="OperatorApp.IApi" behaviorConfiguration="web" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" >
</serviceMetadata>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
<behavior name="ssl">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webBindingSecure">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>