IzzyTwinkly
asked on
Could not find a base address error in WCF
Hi,
I am really new to WCF and I tried to build custom host application.
However, I am getting "An unhandled exception of type 'System.InvalidOperationEx ception' occurred in System.ServiceModel.dll.
Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are[]."
This is my service side of code.
App.config from ConsoleHost project
Thank you so much.
I am really new to WCF and I tried to build custom host application.
However, I am getting "An unhandled exception of type 'System.InvalidOperationEx
Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are[]."
This is my service side of code.
[DataContract]
public class Eval
{
[DataMember]
public string Submitter;
[DataMember]
public DateTime Timesent;
[DataMember]
public string Comments;
}
[ServiceContract]
public interface IEvalService
{
[OperationContract]
void SubmitEval(Eval eval);
[OperationContract]
List<Eval> GetEvals();
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class EvalService : IEvalService
{
List<Eval> evals = new List<Eval>();
public void SubmitEval(Eval eval)
{
evals.Add(eval);
}
public List<Eval> GetEvals()
{
return evals;
}
}
My ConsoleHost program has the following code.namespace ConsoleHost
{
class Program
{
static void Main(string[] args)
{
ServiceHost host = new ServiceHost(typeof(EvalService));
host.AddServiceEndpoint(typeof(IEvalService),
new BasicHttpBinding(),
"http//localhost:8/evals/basic");
host.AddServiceEndpoint(typeof(IEvalService),
new WSHttpBinding(),
"http//localhost:8080/evals/ws");
host.AddServiceEndpoint(typeof(IEvalService),
new NetTcpBinding(),
"net.tcp//localhost:8081/evals");
try
{
host.Open();
Console.Read();
host.Close();
}
catch (Exception e)
{
Console.WriteLine(e);
host.Abort();
}
}
}
}
App.config on the service side:<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>
<services>
<service name="EvalServiceLibrary.EvalService">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8733/Design_Time_Addresses/EvalServiceLibrary/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="EvalServiceLibrary.IEvalService">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
App.config from ConsoleHost project
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
Thank you so much.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.