Hello I have a WCF service library project and I have created a WPF app to host it for testing and that works just fine, but I also created a web app to host it in IIS for production and when I try to connect to the IIs one I never can.
I am using a net.tcp bininding and I have gone in to IIS and added the net.tcp biniding to the web app and the web site.
Basically this is a duplex service with the methods marked as one way. When I call the method in the client the callback never gets called and I end up just sitting there waiting for several minutes before I close the application. When I self host the service I get a response almost immediately on the callback.
Also I have tried using localhost:808 and just localhost. If I use svcutil to generate the config it leaves the port off of the address. I don't get any errors that I am aware of, but I honestly don't really know how to tell if I get any errors it throws from IIS.
Also if I go to http://localhost:9595/EcuWebService/Service.svc I get the page that tells me to use svcutil to generate my client proxy.
As Jocke suggested below I attached a debugger and received this error: The service '/EcuWebService/service' does not exist.
Also here is the contents of my svc file:
<%# ServiceHost Language="C#" Debug="true" Service="EcuWeb.ServiceLib.Contracts.EcuWebServiceMain" %>
below is my Web.config:
<?xml version="1.0"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToActivateService="1" multipleSiteBindingsEnabled="true"/>
<services>
<service name="EcuWeb.ServiceLib.Contracts.EcuWebServiceMain">
<endpoint address="net.tcp://localhost:808/EcuWebService/service" binding="netTcpBinding" bindingConfiguration="" name="netTcp_EcuWebServiceEndpoint" contract="EcuWeb.ServiceLib.Contracts.IEcuWebServiceMain">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:808/EcuWebService/mex" binding="mexTcpBinding" bindingConfiguration="" name="mexTcp_EcuWebServiceEndpoint" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/EcuWebService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
This is the config for the client app. The commented out endpoint is the endpoint that I use when not hosting in IIS and it works.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcp_EcuWebServiceEndpoint" />
</netTcpBinding>
</bindings>
<client>
<!--<endpoint address="net.tcp://localhost:5555/EcuWebService/service"
binding="netTcpBinding" bindingConfiguration="netTcp_EcuWebServiceEndpoint"
contract="EcuWebService.IEcuWebServiceMain" name="netTcp_EcuWebServiceEndpoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>-->
<endpoint address="net.tcp://localhost/EcuWebService/service"
binding="netTcpBinding" bindingConfiguration="netTcp_EcuWebServiceEndpoint"
contract="EcuWebService.IEcuWebServiceMain" name="netTcp_EcuWebServiceEndpoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<services>
<service name="Ecu.Service.Contracts.EcuServiceMain">
<endpoint address="service" binding="netNamedPipeBinding" bindingConfiguration=""
name="netNamedPipe_EcuClientEndpoint" contract="Ecu.Service.Contracts.IEcuServiceMain">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration=""
name="mexNamedPipe_EcuClientEndpoint" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/EcuServiceClient" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Ok I finally got this figured out.
First I had to add:
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:5555/EcuWebService" />
<add baseAddress="http://localhost/EcuWebService" />
</baseAddresses>
</host>
Then for the endpoint I just used:
<service name="EcuWeb.ServiceLib.Contracts.EcuWebServiceMain">
<endpoint address="service" binding="netTcpBinding" bindingConfiguration=""
name="netTcp_EcuWebServiceEndpoint" contract="EcuWeb.ServiceLib.Contracts.IEcuWebServiceMain">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
Then in the client I had to use:
<endpoint address="net.tcp://localhost/EcuWebService/Service.svc/service"
binding="netTcpBinding" bindingConfiguration="netTcp_EcuWebServiceEndpoint"
contract="EcuWebService.IEcuWebServiceMain" name="netTcp_EcuWebServiceEndpoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
When I added the port it didn't work, but once I removed it it worked no problem. Also I doubt the base address is required as IIS is giving the address anyway.
What happens? Do you get an exception? Can you browse it in the IIS?
Your service has:
endpoint address="net.tcp://localhost:808/EcuWebService/mex"
and the client:
endpoint address="net.tcp://localhost/EcuWebService/service"
I think you need provide more details to get a good answer.
Related
I have a WCF service hosted in a Windows Service. I then have a GUI(client) that then communicates to this service. It has recently been reported that communication with the service stops after being idle for 10 minutes.
I have done a bit of research and it looks like the service is discarding the connection due to inactivity. Therefore I want to increase the receive timeout and enable reliable sessions and set an inactivityTimeout to be longer. However when I do this in both the WCF service and clients app.config file I get the following error:
Setting reliableSession enabled="False" causes the client and service to run. ( although only for 10 minutes )
Doing some research the suggestion is this is because of one of the following three reasons:
You have different contracts between client and sender.
You're using a different binding between client and sender.
The message security settings are not consistent between client and sender.
However as far as I can tell the settings / contracts between the client and server are consistent. I'm hoping it's something stupid. Here are my app.config for service and client:
Service
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IHwResourceManagerWcfService" receiveTimeout="infinite" >
<reliableSession enabled="True" inactivityTimeout="infinite"/>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8523/HwResourceManagerWcfService"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IHwResourceManagerWcfService"
contract="WindowsServices.IHwResourceManagerWcfService" name="NetTcpBinding_IHwResourceManagerWcfService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<services>
<service name="MT.Tools.HwResourceManager.WCF.HwResourceManagerWcfService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration=""
contract="MT.Tools.HwResourceManager.WCF.IHwResourceManagerWcfService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8523/HwResourceManagerWcfService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Client
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IHwResourceManagerWcfService" receiveTimeout="infinite" >
<reliableSession enabled="True" inactivityTimeout="infinite"/>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8523/HwResourceManagerWcfService"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IHwResourceManagerWcfService"
contract="WindowsServices.IHwResourceManagerWcfService" name="NetTcpBinding_IHwResourceManagerWcfService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Any help would be greatly appreciated.
There are several issues in your configuration. This project seems to be a class library project. Please use the WCF service application template. Then the base address of the service should be configured in IIS, not in the configuration file. In addition, your binding configuration will not take effect because you don’t apply it in the service endpoint.
<endpoint address="" binding="netTcpBinding" bindingConfiguration=""
Please refer to my example.
Server (WCF service application).
IService.
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(string value);
}
Service1.svc
public class Service1 : IService1
{
public string GetData(string value)
{
return DateTime.Now.ToLongTimeString();
}
}
Web.config
<system.serviceModel>
<services>
<service name="WcfService3.Service1">
<endpoint address="" binding="netTcpBinding"
contract="WcfService3.IService1">
</endpoint>
<endpoint address="mex" binding="mexTcpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Then we deploy the service in the IIS. Before we deploy it, we should enable windows features for net.tcp protocol.
Add the support for the net.tcp protocol on the website.
Then add the site binding.
One more thing we need to pay attention to is ensuring the below service is on running state.
Client. (by adding service reference, the client proxy sends an invocation)
static void Main(string[] args)
{
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
//by default, the nettcpbinding uses windows credential, we should provide server windows account.
client.ClientCredentials.Windows.ClientCredential.UserName = "administrator";
client.ClientCredentials.Windows.ClientCredential.Password = "abcd1234!";
try
{
var result = client.GetData("Hello");
Console.WriteLine(result);
}
catch (Exception)
{
throw;
}
}
App.config.
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IService1">
<security>
<transport sslProtocols="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://vabqia969vm/Service1.svc" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IService1" contract="ServiceReference1.IService1"
name="NetTcpBinding_IService1">
<identity>
<servicePrincipalName value="host/vabqia969VM" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Result.
Feel free to let me know if there is anything I can help with.
After some more reading on this I found both the reason for the error I was seeing and a solution to the connection timeout issue.
The Error - The error was because I had different binding configurations set. By setting to an empty string for both the client and service the error was removed.
The timeout issue - Even with reliable connections enabled and a long timeout for both the inactivity and receive timeouts the 10 minute connection issue remained. I then read a post that suggested that doing a long timeout was the wrong thing to do. Instead it recommended handling the faulted exception and trying to-reconnect.
Im receiving the following error in my WCF program when I send too many xml files:
System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (413) Request Entity Too Large. ---> System.Net.WebException: The remote server returned an error: (413) Request Entity Too Large.
All the other stack overflow answers don't seem to offer me a solution as they mention binding elements in the app.config and my app.config uses services so I'm unsure where to stick the changes. This also makes me wonder if I'm also writing my config file wrong for a production service.
app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="ConfigService.UserService">
<endpoint address="" binding="basicHttpBinding" contract="ConfigService.IUserService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/ProductionProgrammerWebService/UserService/" />
</baseAddresses>
<timeouts openTimeout="00:00:30" />
</host>
</service>
<service name="ConfigService.ConfigurationService">
<endpoint address="" binding="basicHttpBinding" contract="ConfigService.IConfigurationService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/ProductionProgrammerWebService/ConfigurationService/" />
</baseAddresses>
<timeouts openTimeout="00:00:30" />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I have a WCF service that uses NetTcpBinding and I'd like to host it in a WPF application. The service seems to start correctly, but when I'm trying to get it's metadata using 'Add service reference' in visual studio I get this exception:
The URI prefix is not recognized.
Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:8000/Mandrake/mex'.
My service project's App.config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="Mandrake.Service.OTAwareService">
<endpoint address="OTService" binding="netTcpBinding" contract="Mandrake.Service.IOTAwareService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint name="MEX" address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8000/Mandrake/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
And the code in the hosting application:
Uri baseAddress = new Uri("net.tcp://localhost:8000/Mandrake");
ServiceHost host = new ServiceHost(typeof(OTAwareService), baseAddress);
try
{
host.AddServiceEndpoint(typeof(IOTAwareService), new NetTcpBinding(), "OTService");
}
catch (CommunicationException e)
{
Console.WriteLine(e.Message);
host.Abort();
}
The solutions I found to the problem were mainly about adding the 'serviceMetaData' to the service config or providing a mex endpoint. Could you suggest something?
Edit:
Final config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior0">
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Mandrake.Service.OTAwareService" behaviorConfiguration="NewBehavior0">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8036/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>
Hosting application:
host = new ServiceHost(typeof(OTAwareService));
host.Open();
I've managed to figure it out, after enabling the serviceDebug's includeExceptionDetailInFaults it was pretty clear.
Mandrake.Service.IOTCallback.Send operation references a message element [http://tempuri.org/:Send] that has already been exported from the Mandrake.Service.IOTAwareService.Send operation
So there was a Send(OTMessage) operation in the service contract and in the callback interface as well. A rather ugly mistake but I thought I would leave the solution here in case it helps anyone.
I have a Wcf Service Application project that is referenced by and used in different projects. Everything works fine when started Visual Studio 2012 - IIS Express is launched, hosted on localhost.
I tried to use Publish option in right-click menu of my Wcf Service Application. I created a new profile for publishing:
Hitting Publish works. I can access it through internet browser through http://localhost. However, when I launch my application normally, through the executable in bin/Debug - it doesn't work (app crashes). What should I do? Can I upload it and configure it easily with IIS Manager (tried it, but get some access errors)? I would need that in my virtual machine which doesn't have any VS installed.
What's troubling me is that in my Wcf Service Application project's Web.config file I have base addresses specified like this: http://localhost:8733/WcfServiceLibrary/MailingListService/ and in clients App.config I have endpoints with addresses like this: http://localhost/MailingListService.svc. Is it ok to have different ports and addresses (one is in root, the other in WcfServiceLibrary)? It works fine when run in Visual Studio.
Web.config:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="NewsletterEntities" connectionString="metadata=res://*/NewsletterDAL_EF.csdl|res://*/NewsletterDAL_EF.ssdl|res://*/NewsletterDAL_EF.msl;provider=System.Data.SqlClient;provider connection string="Data Source=(local)\SQLEXPRESS;Initial Catalog=Newsletter;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="WCFHost.MessageService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.IMessageService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/MessageService/" />
</baseAddresses>
</host>
</service>
<service name="WCFHost.MailingListService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.IMailingListService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/MailingListService/" />
</baseAddresses>
</host>
</service>
<service name="WCFHost.RecipientService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.IRecipientService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/RecipientService/" />
</baseAddresses>
</host>
</service>
<service name="WCFHost.SenderService">
<endpoint address="" binding="basicHttpBinding" contract="WCFHost.ISenderService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/WcfServiceLibrary/SenderService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMessageService" />
<binding name="BasicHttpBinding_IRecipientService" />
<binding name="BasicHttpBinding_IMailingListService" />
<binding name="BasicHttpBinding_ISenderService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2433/MessageService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMessageService"
contract="MessageServiceReference.IMessageService" name="BasicHttpBinding_IMessageService" />
<endpoint address="http://localhost/RecipientService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRecipientService"
contract="RecipientServiceReference.IRecipientService" name="BasicHttpBinding_IRecipientService" />
<endpoint address="http://localhost/MailingListService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMailingListService"
contract="MailingListServiceReference.IMailingListService"
name="BasicHttpBinding_IMailingListService" />
<endpoint address="http://localhost/SenderService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISenderService" contract="SenderServiceReference.ISenderService"
name="BasicHttpBinding_ISenderService" />
</client>
</system.serviceModel>
</configuration>
dont bother anything. just do the following:
1) enter localhost in service url field.
2) The name of the website you have added inside the inetmgr in the site field.
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.