"Service metadata may not be accessible" impossible to run my WCF service - c#

Good afternoon,
I create a database and then add a WCF service but when I want to run my WCF I have this error "Service metadata may not be accessible".
The problem is that I follow the steps of another topic from this website in order to solve my error, but anyway there is still this restriction and I can't have access to my WCF.
Here is my Web config I tried to modify with the other topic about the same error but do you see any mistakes which can't make my WCF impossible to run ?
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Service3.Service3" behaviorConfiguration="metadataBehavior">
<endpoint
address=""
binding="customBinding" bindingConfiguration="jsonpBinding"
contract="Service3.IService3"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
I tried a lot of changes, like even if I put a localhost address in the first endpoint there is still this error when I run my WCF.
I tried to change the different binding too but nothing changes error still appears ... Need help please !
Thanks for your answers
Edit: I tried to make changes but the error is still here. Here my new Web config file:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Service3.Service3" behaviorConfiguration="metadataBehavior">
<endpoint
address="http://localhost:7488/"
binding="basicHttpBinding"
contract="HostService.IService3" />
<endpoint
address=""
binding="customBinding" bindingConfiguration="jsonpBinding"
contract="Service3.IService3"/>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
<host>
<baseAddresses>
<add baseAddress="http://localhost:7488/Service3.svc" />
</baseAddresses>
</host>
</services>
</system.serviceModel>

Related

System.NullReferenceException for .NET service running on windows server IIS but works locally when running in Visual Studio IIS Express

I have a .NET project that I have inherited, in which I'm having issues getting a service to return properly when running on Windows Server IIS.
The ExceptionType is System.NullReferenceException
The Stacktrace is at Integra.HLX.SB.Web.WS_Reps..ctor() at CreateIntegra.HLX.SB.Web.WS_Reps() at System.ServiceModel.InstanceContext.GetServiceInstance(Message message) at System.ServiceModel.Dispatcher.InstanceBehavior.EnsureServiceInstance(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
This error gets thrown when I attempt to POST to the service's endpoint. I'm assuming I'm missing something within the web.config to allow this to work on IIS from a Windows Server, or maybe missing a feature setting within IIS on Windows Server.
Here is the relevant web.config settings...
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding>
<binding name="binding1">
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="Integra.HLX.SB.Web.WS_RepsAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="Integra.HLX.SB.Web.WS_ClientContactsAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="Integra.HLX.SB.Web.WS_ContactUniverseNameAddressesAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="Integra.HLX.SB.Web.WS_UsersAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="jsonBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="RESTbehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Integra.HLX.SB.Web.WS_Reps">
<endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_RepsAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_Reps" />
</service>
<service name="Integra.HLX.SB.Web.WS_ClientContacts">
<endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_ClientContactsAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_ClientContacts" />
</service>
<service name="Integra.HLX.SB.Web.WS_ContactUniverseNameAddresses">
<endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_ContactUniverseNameAddressesAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_ContactUniverseNameAddresses" />
</service>
<service name="Integra.HLX.SB.Web.WS_Users">
<endpoint address="" behaviorConfiguration="Integra.HLX.SB.Web.WS_UsersAspNetAjaxBehavior" bindingConfiguration="binding1" binding="webHttpBinding" contract="Integra.HLX.SB.Web.WS_Users" />
</service>
<service name="Integra.HLX.SB.Web.WS_SpeakerDataFeed" behaviorConfiguration="RESTbehavior">
<endpoint address="" bindingConfiguration="binding1" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" contract="Integra.HLX.SB.Web.IWS_SpeakerDataFeed" />
</service>
<service name="Integra.HLX.SB.Web.WS_DashboardDataFeed" behaviorConfiguration="RESTbehavior">
<endpoint address="" bindingConfiguration="binding1" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" contract="Integra.HLX.SB.Web.IWS_DashboardDataFeed" />
</service>
</services>
</system.serviceModel>
Any help would be appreciated. Thanks!
I was able to answer my own question. The fix for me in this instance was the web.config on the production server was missing the line <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
I found out more information by checking the Windows Event Viewer logs and found this key bit of information The service cannot be activated because it requires ASP.NET compatibility.
After inserting the aforementioned line into the web.config and restarting the AppPool and server, the service started working properly. I hope this helps anybody in the future.

Can't launch service with net.tcp binding error 10049

I have a problem with launching a WCF service using net.tcp endpoints. I'm getting an 10049 error.
My app.config:
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehaviour0"
name="Tinkl.Server.Services.Authentication.AuthenticationService">
<endpoint name="httpEndpoint"
address="reg"
binding="basicHttpBinding"
contract="Tinkl.Server.Services.Authentication.IRegistrationService" />
<endpoint name="httpEndpoint"
address="auth"
binding="basicHttpBinding"
contract="Tinkl.Server.Services.Authentication.IAuthorizationService" />
<!--
<endpoint name="tcpEndpoint"
address="net.tcp://78.26.210.203:50050/reg"
binding="netTcpBinding"
contract="Tinkl.Server.Services.Authentication.IRegistrationService" />
<endpoint name="tcpEndpoint"
address="net.tcp://78.26.210.203:50051/auth"
binding="netTcpBinding"
contract="Tinkl.Server.Services.Authentication.IAuthorizationService" />
-->
<endpoint name="mexEndpoint"
address="mex"
binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://78.26.210.203:50076/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour0">
<!--<serviceMetadata />-->
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
There are 2 endpoints with netTcpBinding and 2 same exact with basicHttpBinding.
The problem appears when I'm trying to use netTcpBinding endpoints, I'm getting an error, but with basicHttpBinding it works fine...
I'm hosting the WCF service in a console application.
Program code
ServiceHost authenticationHost = new ServiceHost(typeof(AuthenticationService));
authenticationHost.Open();
Console.WriteLine("close <ENTER>\n");
Console.ReadLine();
authenticationHost.Close();
Maybe someone faced a similar problem?
If needed, I will give all the necessary additional information
Thank you in advance!
Try to replace lines
net.tcp://78.26.210.203:50050/reg
with
net.tcp://localhost:50050/reg
And the same for /auth endpoint.

The binding at system.serviceModel/bindings/wsHttpBinding does not have a configured binding

I'm trying to create a second endpoint in my WCF web service. I can bring up the new endpoint's "Happy Page" by putting the domain URL in my browser, so I know that IIS can find the service, using my user account, properly.
However, if I try to run the web page that calls the service, I'm getting the error below
The binding at system.serviceModel/bindings/wsHttpBinding does not have a configured
binding named 'WSHttpBinding_IMonetToDss'. This is an invalid value for
bindingConfiguration. (D:\webcontent\Monet\web.config line 178).
Since this section of the config file is auto-generated by Visual Studio when I create the service reference the bindingConfiguration value is WSHttpBinding_IMonetToDss.. which it's saying it shouldn't be.
Below are both enpoints pulled from the web.config. The first endpoint /OKeeffe/OKeeffe.svc is working properly. The second endpoint for /OKeeffe/MonetToDss.svc is having the issue.
<client>
<endpoint address="http://insidesoap.dev.symetra.com/Escher/EscherService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IEscherService"
contract="Escher.IEscherService" name="WSHttpBinding_IEscherService" />
<endpoint address="http://insideapps.dev.symetra.com/OKeeffe/OKeeffe.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAgentPayments"
contract="AgentPayments.IAgentPayments" name="WSHttpBinding_IAgentPayments">
<identity>
<userPrincipalName value="s.AgentData.dev" />
</identity>
</endpoint>
<endpoint address="http://insideapps.dev.symetra.com/OKeeffe/MonetToDss.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMonetToDss"
contract="MonetToDss.IMonetToDss" name="WSHttpBinding_IMonetToDss">
<identity>
<userPrincipalName value="s.AgentData.dev" />
</identity>
</endpoint>
</client>
EDIT
Here's the system.serviceModel section of the web service config file
<system.serviceModel>
<services>
<service name="OKeeffeDataService.MonetToDss"
behaviorConfiguration="MonetToDssBehaviors" >
<endpoint address=""
binding="wsHttpBinding"
contract="OKeeffeDataService.IMonetToDss" />
</service>
<service name="OKeeffeDataService.AgentPayments"
behaviorConfiguration="OKeeffeBehavior" >
<endpoint address=""
binding="wsHttpBinding"
contract="OKeeffeDataService.IAgentPayments" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="OKeeffeBehavior">
<!-- 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="true"/>
</behavior>
<behavior name="MonetToDssBehaviors" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
are you sure you have defined a binding named "WSHttpBinding_IMonetToDss" in your config file? something like this...
<bindings>
<wsHttpBinding name="WSHttpBinding_IMonetToDss">
...
</wsHttpBinding>
<bindings>

Could not find default endpoint element that references contract

I have self hosted a WCF service from a console application (HOST). I am calling HOST from another console application (PARENT). When I run PARENT, everything works fine like the WCF hosted successfully and instance of service reference is also getting created. The PARENT application is actually a plug-in for another big unmanaged application(BIG A). When I start the PARENT application from BIG A , the console application self hosts the service successfully. However I am getting following error while creating the instance of service.
Could not find default endpoint element that references contract 'CalculatorServiceReference.ICalculatorService' 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.
The configuration files are as follows.
•Configuration file of HOST
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="NewBehavior" name="HybridCalcService.CalculatorService">
<clear />
<endpoint address="mex" binding="mexHttpBinding" name="Mex" contract="IMetadataExchange"
listenUriMode="Explicit">
</endpoint>
<endpoint address="net.tcp://localhost:8523/CalcService" binding="netTcpBinding"
name="Tcp" contract="HybridCalcService.ICalculatorService" listenUriMode="Explicit">
</endpoint>
<endpoint address="HTTP" binding="basicHttpBinding" bindingConfiguration=""
name="HTTP" contract="HybridCalcService.ICalculatorService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Hybridservice" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
•And the config of PARENT is
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="NewBehavior" name="HybridCalcService.CalculatorService">
<clear />
<endpoint address="mex" binding="mexHttpBinding" name="Mex" contract="IMetadataExchange"
listenUriMode="Explicit">
</endpoint>
<endpoint address="net.tcp://localhost:8523/CalcService" binding="netTcpBinding"
name="Tcp" contract="HybridCalcService.ICalculatorService" listenUriMode="Explicit">
</endpoint>
<endpoint address="HTTP" binding="basicHttpBinding" bindingConfiguration=""
name="HTTP" contract="HybridCalcService.ICalculatorService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Hybridservice" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
Can anyone help me in this issue?
I believe that the config info has to be in the config file of the main application. Adding that info to the config of BigA should solve the problem.
This looks pretty similar to what I did for a custom channel. if i remember correctly this would go into HOST, and then you wouldn't need anything in the other configs.

UserName authentication for WCF WebService

I am having an absolute nightmare trying to get this to work. Can someone please point me in the right direction or tell me where I am going wrong?
I have created a certificate which is located in LocalMachine\My.
I have a console application that
hosts a WCF WebService.
I have an ASP.NET website that connects to the
WebService.
I have followed advice on this site and others and documentation but seem to be missing something as my ASP.NET website can still connect to the WebService without authentication.
So to summarise: the website connects to the web service fine which indicates the authentication isn't working as I have yet to tell the website what security settings it needs to connect to the webservice.
Thankyou in advance
Here is the info:
Console App (hosting WebService)
Program.cs
WebService Host (console app) uses the following code in
ServiceHost host = new ServiceHost(typeof(MyService));
host.Open();
App.Config (abbreviated)
<services>
<service behaviorConfiguration="MetaDataBehaviour" name="MyService_Provider.MyService">
<clear />
<endpoint address="myService" binding="wsHttpBinding" contract="MyService_Provider.IMyService"
listenUriMode="Explicit" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080" />
</baseAddresses>
</host>
</service>
</services>
MyService Provider
App.Config (abbreviated)
<system.serviceModel>
<bindings />
<client />
<services>
<service behaviorConfiguration="MyService_Provider.Service1Behavior"
name="MyService_Provider.MyService">
<endpoint address="" binding="wsHttpBinding" contract="MyService_Provider.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/MyService_Provider/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyService_Provider.Service1Behavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyService_Provider.CredentialsValidator,MyService_Provider"/>
<serviceCertificate findValue="mycert" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
You haven't specified any security requirements for your service. Have a look at this article for an example of configuring a service to use certificates.

Categories