I am getting the following error when trying to access a WCF service.
Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding. Registered base address schemes are [https].
Here's my config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DefaultHttpBinding"
maxBufferSize="655360"
maxReceivedMessageSize="655360">
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://MySite.com/MyVirtualDir/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<services>
<service behaviorConfiguration="DefaultBehavior"
name="MyWcfService">
<endpoint address="http://MySite.com/MyVirtualDir/MyWcfService.svc"
binding="basicHttpBinding"
bindingConfiguration="DefaultHttpBinding"
contract="MyNamespace.IMyWcfService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceMetadata httpGetEnabled="true"
policyVersion="Policy15"/>
<serviceDebug httpHelpPageEnabled="true"
includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
And here's my .scv file
<%# ServiceHost Language="C#" Debug="true" Service="MyWcfService" Factory="MyWcfServiceHostFactory"%>
To give some more background that may or may not be helpful
The service works fine in our DEV environment. This error is only
occurring in our TEST and PROD environments. The only discernable
difference between environments that i am aware of is that TEST and PROD are using a
load balancer.
The service is hosted in IIS 5.1 on all environments
The service has been written in dot.net 3.5 and is activated by a
WebServiceHost factory
I have not specified https anywhere in my config file
SSL has NOT been enabled in IIS on any of the environments. Anonymous access has been enabled (security implementation will come later on).
Any help would be much appreciated as this is a complete show stopper for our project. I have throurghly searched the web for solutions to this problem, but nothing seems to relate to my my particular set up.
So for me, the fix for this issue was to remove the mex binding as per some of your suggestions. I also removed the servicemetadata section from the DefaultBehavior in config.
This fix only hides the original issue as I still have no idea why the mex binding was registered as https. But I can now consume my web service, even if i can't retrieve the metadata from it - that's not a problem in my case.
Here's the corrected config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DefaultHttpBinding"
maxBufferSize="655360"
maxReceivedMessageSize="655360">
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://MySite.com/MyVirtualDir/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<services>
<service behaviorConfiguration="DefaultBehavior"
name="MyWcfService">
<endpoint address="http://MySite.com/MyVirtualDir/MyWcfService.svc"
binding="basicHttpBinding"
bindingConfiguration="DefaultHttpBinding"
contract="MyNamespace.IMyWcfService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceDebug httpHelpPageEnabled="true"
includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Try enabling tracing on your service to check why things fail in your test/production environment. To enable tracing check this link
Are you sure that the MyWcfServiceHostFactory doesnt have any code related to configuration (i.e. building configuration via c# code)
Related
I have a self hosted WCF service, that should enable recording of some data that clients send.
(In my case, machines shall report done actions, that the service logs into one xml file for each machine, which is on the file system of the service host.)
For the file access there are global mutexes for each file.
The report method receives a stream, and processes that data until the file writing operations are done.
The problem is, that when I simulate the dataset reporting (1000-2000 reports, each client reports one dataset each 50-100ms, which is not a huge frequency I think) on multiple clients,
my wcf service connection sometimes seems to close (http response 400).
Furthermore the service throws Exceptions
Exception thrown: 'System.ServiceModel.CommunicationException' in System.ServiceModel.dll
Exception thrown: 'System.Net.HttpListenerException' in System.dll
and on the client side some Tasks (one task for each request) are getting canceled
Unhandled Exception: System.Threading.Tasks.TaskcanceledException...
Firstly I thought that the Problem is in the point of file accessing, but now
I think that the problem should be in the WCF Service configuration.
Because I removed the Methods processing (just return true), started 5 clients to 5000 requests at 50ms request frequency and the problem occured.
Here's my Service Configuration
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
</startup>
<!-- Webservice Configuration -->
<system.serviceModel>
<services>
<service behaviorConfiguration="Program.ServiceBehavior"
name="Program.HttpService.HttpService">
<endpoint address=""
binding="webHttpBinding"
bindingConfiguration="RestBinding"
contract="Program.HttpService.IFbmHttpService"
behaviorConfiguration="web">
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
name="MetadataEndpoint"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Program.ServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="RestBinding"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<!--<readerQuotas maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" />-->
<security mode="None">
</security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel
<system.web>
<httpRuntime maxRequestLength="2000000"/>
</system.web>
<system.net>
<connectionManagement>
<add address="*" maxconnection="100"/>
</connectionManagement>
</system.net>
</configuration>
I'm new to building Web Services and WCF in general, although I've done well so far I've ran into The following issue issue I can't seem to get past.
Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding. Registered base address schemes are [].
I have my app.config set up as such
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WcfSoapServiceBinding">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="WcfSoapServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="WcfSoapServiceBehavior" name="WcfSoapService.Service1">
<endpoint binding="wsHttpBinding" bindingConfiguration="WcfSoapServiceBinding"
contract="WcfSoapService.IService1" />
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I set security mode to "None" so it uses HTTP instead of HTTPS and I also set the httpGetEnabled to true. I've tried some different options I've found online for some time, but none have helped so far. I'm using Ewald Hofman's example on how to use WCF to subscribe to TFS.
http://www.ewaldhofman.nl/post/2010/08/02/How-to-use-WCF-to-subscribe-to-the-TFS-2010-Event-Service-rolling-up-hours.aspx
I feel like I am close but this is the one thing I can't get past. My ultimate goal is to take the Soap Request from TFS and parse through its data. Being new to WCF and Web servers I'm unsure on what this error is actually telling me is wrong as well. So I have two questions.
1) What does this error mean is wrong? More specifically what does "Registered base address schemes are []" mean.
2) How could I go about fixing the error?
In your service section add base address or add address element for your endpoint.
<services>
<service behaviorConfiguration="WcfSoapServiceBehavior" name="WcfSoapService.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8182/MyService"/>
</baseAddresses>
</host>
<endpoint address=""
binding="wsHttpBinding" bindingConfiguration="WcfSoapServiceBinding"
contract="WcfSoapService.IService1" />
</service>
I have looked through all of the other solutions and none of them are working. I am hosting a WCF service using IIS. The following is my web.config (the default for when I added a WCF service):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
<customErrors mode="Off" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
All is good and I can access my wcf service in the browser using http://www.domain.com/path/service.svc and https://www.domain.com/path/service.svc - now I add a web reference to https://www.domain.com/path/service.svc in a windows console application and the following is in my app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="defaultBasicHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://www.domain.com/path/service.svc" binding="basicHttpBinding" bindingConfiguration="defaultBasicHttpBinding" contract="DomainExt.IExt" name="BasicHttpBinding_IExt" />
</client>
</system.serviceModel>
</configuration>
The following code is what I am using to test the service:
public static String DoPing()
{
ExtClient client = new ExtClient("BasicHttpBinding_IExt", "https://www.domain.com/path/service.svc");
return client.DoPing();
}
After I run this I get the following exception:
There was no endpoint listening at https://www.domain.com/path/service.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The inner-exception sates:
"The remote server returned an error: (404) Not Found."
This service works fine over http but fails on https. How can I fix this? Please note that I'm accessing this service using Windows Console and NOT through ASP.NET; ASP.NET is only hosting the WCF service.
Try setting httpsGetEnabled="true" rather than httpGetEnabled
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" />
EDIT: I'm also curious why you chose the BasicHttpBinding if you're using SSL. Why not use the WsHttpBinding?
EDIT2: Are you missing a <services> node in your host config file? I wouldn't think you could create a client without one. You can right click on your app.config file and configure it there... Something like this:
<services>
<service behaviorConfiguration="MyServiceBehavior" name="MyService">
<endpoint address="" binding="defaultBasicHttpBinding" bindingConfiguration="basicBinding" contract="IMyService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
I am trying to create a WCF Service with only Transport Security so I do not need SSL.
I keep geting this error message when I run it:
Could not find a base address that matches scheme https for the endpoint with binding
BasicHttpBinding.
My Web.config file looks like this:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Binding1">
<security mode="Transport">
<transport clientCredentialType="Basic"></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="AutoSenderWCFService.AutoSenderService">
<endpoint binding="basicHttpBinding" bindingConfiguration="Binding1"
contract="AutoSenderWCFService.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="AutoSenderWCFService.MyValidator, AutoSenderWCFService"/>
</serviceCredentials>
<!-- 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"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Transport security means securing your channel with SSL and hence you would need a certificate.
If you dont want to use SSL but want to pass username password over the channel then you can use ClearUsernameBinding that sends the username password over the channel in clear text.
NOTE: Make sure you use this only when you are confident that you client and server channel is secure like behind a firewall that provides security.
I cant see any address in there - add an address to your endpoint and should be ok
so:
<endpoint binding="basicHttpBinding" address="https://address" bindingConfiguration="Binding1"
contract="AutoSenderWCFService.IService1" />
In my case I was trying to test a wcf web service setup on a testing server without ssl. I changed the security mode to none and it started working for me.
I have developed window application and in that i am calling WCF at particular time interval however there is no error in inserting data into database through WCF but in log entry i am getting one error regarding WCF Endpoint as per below
2011-22-09 10:16>>Error: There was no endpoint listening at
myserviceUrl(.svc) that could accept the message. This is often
caused by an incorrect address or SOAP action. See InnerException, if
present, for more details.
app.config file as per below and i guess that probably error should be in below configuration
<client>
<endpoint address="myserviceUrl(.svc)"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF"
contract="Dashboard2WCFData.IApicaAzureMonitorAgentReceiverWCF"
name="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF" />
</client>
Below is my (WCF)service's configuration..
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</configSections>
<dataConfiguration defaultDatabase="Connectionstr"/>
<connectionStrings>
<add name="Connectionstr" connectionString="myconnectionstring"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Please help me to sort out of this issues.
Thanks.
You need to make sure that the endpoint is configured at the service side, not just your client. In other words, if the client uses myserviceUrl(.svc), the address needs to be specified in the service's config file.
Based on the error message you got, try this in the service's config file:
<endpoint address="myserviceUrl(.svc)"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF"
contract="Dashboard2WCFData.IApicaAzureMonitorAgentReceiverWCF"
name="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF" />
Note that you'll need to ensure your service has the appropriate binding section named "BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF".
If you need a more thorough example, post your service's config file and we'll help you out.
UPDATE
Add an endpoint section, and a binding section if you have any values set to other than the default values:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="myServiceName">
<endpoint address="myserviceUrl(.svc)"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF"
contract="Dashboard2WCFData.IApicaAzureMonitorAgentReceiverWCF"
name="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF"/>
<endpoint name="mexHttpBinding"
contract="IMetadataExchange"
binding="mexHttpBinding"
address="mex" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IApicaAzureMonitorAgentReceiverWCF" />
</basicHttpBinding>
</bindings>
In the <binding name="" section is where you'd set the values for the binding. If you don't do this (and don't specify the section in the endpoint's bindingConfiguration attribute) WCF will use the default values for basicHttpBinding.
NOTE: With WCF 4.0 and later, you actually don't need to specify an endpoint (or create a .svc file if hosting under IIS), as WCF will supply a default endpoint based on the URI of the service. See A Developer's Introduction to Windows Communication Foundation 4 for details on this and other new features in 4.0.
You need to specify in address attribute the whole virtual path
for example http://localhost/yousite/myservice.svc