I created a WCF service in separate project name is AaWs then added this project in a website project as a reference . website project name is AaNuWs
in website project web.config file is
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehavior">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="mexBehavior" name="AaWs.RxtraIntroService">
<endpoint address ="AaWs" binding="basicHttpBinding" contract="AaWs.IRxIntro">
</endpoint>
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8080" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
then uploaded this website project on my web server.
then give the service reference in my new project from my website with a name space
IntroService
http://mywebsite/IntroService.svc?wsdl
new system create a new app.config file for me
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IRxIntro" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://mywebsite/IntroService.svc/RecoverInfoTechAaWs"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRxIntro"
contract="IntroService.IRxIntro" name="BasicHttpBinding_IRxIntro" />
</client>
</system.serviceModel>
</configuration>
but now when i trying to access this service i am getting a error.
System.InvalidOperationException: Could not find default endpoint
element that references contract 'IntroService.IRxIntro' in the
ServiceModel client configuration section. This might be because no
configuration file was found for your application, or because no
endpoint element matching this contract could be found in the client
element.
please help me on this
You need to confirm that the app.config is in the root folder with your executable. Then confirm that the app.config has the proper value for:
<client>
<endpoint ... contract=""
From the information you provided, the address information does not look correct. Your service has an overall address of "http://localhost:8080/AaWs" but your service reference (wsdl url) shows "http://mywebsite/IntroService.svc?wsdl". You surely want to make sure that you are pointing to the correct service when generating the reference.
Remove name="BasicHttpBinding_IRxIntro" attribute from endpoint configuration of app.config.
Related
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 a WCF service in a service library and I'm trying to host it in a WCF service application. I modified the .svc file accordingly
<%# ServiceHost Language="C#" Debug="true" Service="Mandrake.Service.OTAwareService" Factory="Mandrake.Service.OTServiceHostFactory" %>
And I added the stuff that was originally in the service library's app config to the service application's web.config file. I thought it overrides the settings defined in the library's app.config, but it turned out if I remove the app.config file from the library and host the service application on IIS with the web.config containing the necessary endpoint setup (which worked previously) the service doesn't get started and says I have no endpoint defined.
My web.config's servicemodel section is as follows:
<system.serviceModel>
<serviceHostingEnvironment>
<serviceActivations>
<add service="Mandrake.Service.OTAwareService"
factory="Mandrake.Service.OTServiceHostFactory"
relativeAddress="OTService.svc"/>
</serviceActivations>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="StandardBehavior">
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Mandrake.Service.OTAwareService" behaviorConfiguration="StandardBehavior">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8062/OTService"/>
</baseAddresses>
</host>
<endpoint address="" binding="netTcpBinding" name="TcpEndpoint" contract="Mandrake.Service.IOTAwareService" />
<endpoint address="mex" binding="mexTcpBinding" name="MetadataEndpoint" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
Is there a way I can host this service from the service library in my service application?
Most probably you may not have net.tcp binding enabled on website where you are hosting your service application. Check in iis if net.tcp is there in list of bindings.
Ok so here is my scenario.
I have made a WCF Library project. Configured my app.config file. I then created a new console application. Added my WCF Library project to the console app. Then I copied the config file over to my server console app. However, when I run the console application it throws an exception and essentially states that it cant see the app.config file. However, the app.config is clearly inside of the server console application. I can add my endpoints programmatically and make the service work. However, that is not my intention. Is there some sort of trick in order to get the ServiceHost to use the app.config, or more importantly the project to see the app.config?
My app.config
<configuration>
<configSections>
</configSections>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="serviceBehavior" name="Services">
<endpoint address="CompanyService" binding="netTcpBinding" bindingConfiguration=""
name="NetTcpBinding" contract="Services.ICompany" />
<endpoint binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8732/Services/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
My Host Service code:
using (ServiceHost host = new ServiceHost(typeof(Company))) {
host.Open();
Console.WriteLine("Press <ENTER> to terminate the host service");
Console.ReadLine();
}
It then throws this exception:
Unhandled Exception: System.InvalidOperationException: Service 'Services.Company' has zero application (non-infrastructure) endpoints. This might
be because no configuration file was found for your application, or because no
service element matching the service name could be found in the configuration fi
le, or because no endpoints were defined in the service element.
What are you naming the app.config file when you copy it over to the console app? There are specific rules that will need to be followed.
If the console app has an executable name of, e.g. "consoleapp.exe", then the app.config will have to have the name "consoleapp.exe.config"
Is the problem that you have called the file app.config, and not yourprogramname.exe.config?
#Jaochim The error says it's looking for a service named Services.Company while your config seems to have it attributed with name="Services" Try changing that.
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)
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