http wcf error "Could not find a base address that matches scheme https for the endpoint with binding MetadataExchangeHttpsBinding..." - wcf

am getting this error when i try to call my custom svc file from sharpoint. i have posted my web.config file here, could you guys tell wats wrong with this.
am trying to have my custom webservice in the sharepoint, so i created a project but due to this error i could not browse my web methods.
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="AlertWcfService.CustomServiceBehaviour"
name="AlertWcfService.AlertService">
<endpoint address="http://localhost:2000/" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfiguration"
contract="AlertWcfService.IAlertService" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:2000/"></add>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfiguration">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="AlertWcfService.CustomServiceBehaviour">
<!--<serviceMetadata httpsGetEnabled="false"/>-->
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

The error is that you're not using HTTPS, but you're using an MEX binding for HTTPS rather than HTTP. TO fix this, change this line:
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
To
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

In your interface declaration IAlertService, add the name attribute beside the namespace if you do not have it yet...
[ServiceContract(Name = "NameNeeded", Namespace = "http://blahbalh")]
public interface IAlertService
{
.....
}

Related

WCF Setting Security to None fails

I have a service that is working fine using the default security (Windows as far as I know). But I need to enable mi service to work across different domains, so I am trying to disable security for test purposes.
Here's the original client :
Client app.config
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IMyService">
<security>
<transport clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://me.domain.local/MyService/Service.svc"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyService"
contract="MyService.IMyService" name="NetTcpBinding_IMyService">
<identity>
<servicePrincipalName value="host/me.domain.local" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Now, I set this security tag from Windows to None and I will need to to the same in the Service side but it seems that I'm failing to do so
Heres the original working app.config of the Service
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="MyServiceWCF.MyService">
<endpoint address="" binding="wsHttpBinding" contract="MyServiceWCF.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/MyServiceWCF/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I tried adding this tag but it would not work
<bindings>
<netTcpBinding>
<binding name="netTcpBindingConfig" transferMode="Buffered" maxReceivedMessageSize="5242880">
<readerQuotas maxArrayLength="5242880" />
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
Edit 1 :
So I corrected the client app.config code to set Security mode to None. I also try to use Net Tcp binding.
<bindings>
<netTcpBinding>
<binding name="MyBinding">
<security mode="None">
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://me.domain.local/MyService/Service.svc"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyService"
contract="GService.IMyService" name="NetTcpBinding_IMyService">
<identity>
<servicePrincipalName value="host/me.domain.local" />
</identity>
</endpoint>
</client>
Now for the server side I tried this but wont work either. I really think Im missing a point here.
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IMyService">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="MyServiceWCF.MyService">
<endpoint address="" binding="wsHttpBinding" contract="MyServiceWCF.IMyService" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="" binding="netTcpBinding" contract="MyServiceWCF.IMyService" bindingConfiguration="NetTcpBinging_IMyService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/MyServiceWCF/Service1/" />
</baseAddresses>
</host>
</service>
</services>
You don't have to change to tcp.
Just add a basic http endpoint for your service:
<endpoint address="http://rofl.lol" binding="basicHttpBinding" bindingConfiguration="BasicHttpBindingSettings" contract="roflservice" bindingName="BasicHttpBindingSettings/>
And set the security to none in you binding:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBindingSettings">
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>

ServiceSecurityContext.Current is null in WCF

I'm trying to retrieve the logged in windows user in a WCF service.
I've tried using ServiceSecurityContext but Current is always null.
ServiceSecurityContext.Current.WindowsIdentity.Name
I've also tried using OperationContext. In this case ServiceSecurityContext returns as null.
OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name
Here's my web.config:
<bindings>
<basicHttpBinding>
<binding name="HttpWindowsBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
also
<authentication mode="Windows"/>
Can anyone see what I'm doing wrong?
UPDATE:
I abandoned trying to get ServiceSecurityContext to work. In the end, I found a solution by setting aspNetCompatibilityEnabled="true".
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
I also added the following attribute to my service class:
[System.ServiceModel.Activation.AspNetCompatibilityRequirements(RequirementsMode = System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode.Required)]
This allowed me to retrieve the windows user with:
HttpContext.Current.User.Identity.Name
I got the same error and managed to solved it, you need not to use basichttpBinding. bellow is my config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MSADC">
<security mode ="Message">
<transport clientCredentialType="Windows" />
<message establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="WCFAuthentication.WCFAuthentication">
<endpoint bindingConfiguration="MSADC" address="" binding="wsHttpBinding" contract="WCFAuthentication.IWCFAuthentication">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8088" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
<appSettings>
<add key="wcf:disableOperationContextAsyncFlow" value="false" />
</appSettings>
</configuration>

WCF WPF Silverlight wsDualHttpBinding pollingDuplexHttpBinding

I'm fighting hours on hours to get this Silverlight duplex to work but fail after fail ,
I have A)WCF Service Appllication B) WPF Client C) Silverlight Client ( Do I need +host ?! )
I connect successfully A<=>B - working good , my problem is A<=>C (Silverlight Duplex Client)
Can I have 2 endpoints somehow ? wsDualHttpBinding & pollingDuplexHttpBinding ? Tried and fail
An endpoint configuration section for contract 'Service2.IService1' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.
Can pollingDuplexHttpBinding works on WPF ?
Help ! Thanks !
Web.Config
<!-- Register the binding extension from the SDK. -->
<extensions>
<bindingExtensions>
<add name="pollingDuplexHttpBinding"
type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,
System.ServiceModel.PollingDuplex,
Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
</extensions>
<client>
<endpoint address="http://localhost:8732/Service1/" binding="wsDualHttpBinding" bindingConfiguration="wsDualHttpBinding" contract="TheWCFService.IService1" name="WSDualHttpBinding_Service1" />
</client>
<bindings>
<wsDualHttpBinding>
<binding name="wsDualHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483646" maxArrayLength="2147483646" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</wsDualHttpBinding>
<pollingDuplexHttpBinding>
<binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
duplexMode="MultipleMessagesPerPoll"
maxOutputDelay="00:00:07"/>
</pollingDuplexHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="" name="TheWCFService.Service1">
<endpoint address=""
binding="wsDualHttpBinding"
bindingConfiguration="wsDualHttpBinding"
contract="TheWCFService.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
contract="IMetadataExchange" />
<!--<endpoint
address="/2"
binding="pollingDuplexHttpBinding"
bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
contract="TheWCFService.IService1">
</endpoint>-->
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above 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" />
<serviceThrottling maxConcurrentSessions="500" maxConcurrentCalls="500" maxConcurrentInstances="500" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
So yes It's possible more than 2 endpoints :
Step I :
<endpoint address="wsDualHttpBinding"
binding="wsDualHttpBinding"
bindingConfiguration="wsDualHttpBinding"
contract="TheWCFService.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
contract="IMetadataExchange" />
<endpoint
address="pollingDuplexHttpBinding"
binding="pollingDuplexHttpBinding"
bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
contract="TheWCFService.IService1">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Service1/" />
</baseAddresses>
</host>
Step II :Very Important : WCF Cross Domain SecurityException
http://www.itscodingtime.com/post/Silverlight-to-WCF-Cross-Domain-SecurityException.aspx
Step III :
Silverlight Client :
var x = new WCFService.Service1Client(
new PollingDuplexHttpBinding { DuplexMode = PollingDuplexMode.MultipleMessagesPerPoll, },
new EndpointAddress(#"http://localhost:59732/Service1.svc/pollingDuplexHttpBinding")
);
WPF Client :
> _objProxy = new Service1Client(new InstanceContext(this),
> "WSDualHttpBinding_IService1");

WCF .config file - something is plainly wrong

Folks,
I've got something wrong with this .config for my WCF. When I send data to it more than 8192 bytes (the default) it fails, telling me my "maxStringContentLength" is only 8192. I think I have it set here to 10,000,000.
Any clues?
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding" maxReceivedMessageSize="50000000" maxBufferPoolSize="50000000" messageEncoding="Mtom">
<readerQuotas maxDepth="200" maxStringContentLength="10000000" maxArrayLength="16384" maxBytesPerRead="10000000" maxNameTableCharCount="16384" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="PsychCoverage.WcfMT.Admin">
<endpoint address="" binding="wsHttpBinding" contract="PsychCoverage.Common.IAdmin">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="wsHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfMT/Admin/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior >
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
You do have it set, but you're not referencing it in the endpoint element, so .NET is using the default for wsHttpBinding (8192). Add the config you specified using the bindingConfiguration attribute of the endpoint element:
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBinding" contract="PsychCoverage.Common.IAdmin">
Also, I'd recommend using a different name than wsHttpBinding to prevent confusion.

WCF with custombinding on both http and https

I have a WCF service with custombinding and it is working fine on either http or https. But I have totally no idea about how can I make it available on both http and https?
Also is it possible to do that?
Here's my configuration in web.config.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="customBinding0">
<binaryMessageEncoding />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="MyWCFService">
<endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
contract="MyWCFService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
Thanks
You'll need to have two endpoints, one for HTTP and another for HTTPS. It should work just fine.
<bindings>
<customBinding>
<binding name="customBindingHTTP">
<binaryMessageEncoding />
<httpTransport />
</binding>
<binding name="customBindingHTTPS">
<binaryMessageEncoding />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="MyWCFService">
<endpoint address=""
binding="customBinding"
bindingConfiguration="customBindingHTTP"
contract="MyWCFService" />
<endpoint address=""
binding="customBinding"
bindingConfiguration="customBindingHTTPS"
contract="MyWCFService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>