Can't get Metadata Publishing for my WCF webHttpBinding Service - wcf

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>

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 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>

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

<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.

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>

WCF HttpsGetUrl A registration already exists for URI

This is similar to other Stack postings, but slightly different in that I am only hosting a single wsHttp endpoint (and the mex). When I leave the httpsGetUrl empty, it shows the server name instead of the public uri that I need (for the wsdl)
Here is the important part of the config.
<service behaviorConfiguration="myServiceBehaviors" name="WebApplication1.Service1">
<clear/>
<endpoint behaviorConfiguration="flatwsdl" address="mex" binding="mexHttpsBinding" bindingConfiguration="mexHttpsBinding"
contract="IMetadataExchange" listenUriMode="Explicit">
</endpoint>
<endpoint behaviorConfiguration="flatwsdl" address="wsHttp" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfig"
contract="WebApplication1.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehaviors">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://mydomain.com/integration/Service1.svc" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="flatwsdl">
<wsdlExtensions />
</behavior>
</endpointBehaviors>
</behaviors>
any suggestions?
If you want the public URI, you should use the <useRequestHeadersForMetadataAddress> behavior in your service behavior, that's exactly what this behavior is for.
<behavior name="myServiceBehaviors">
<useRequestHeadersForMetadataAddress />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpsGetEnabled="true" />
</behavior>