Hosting 2 WCF Service in one windows service

  • Thread starter Thread starter Hakan Fatih YILDIRIM
  • Start date Start date
H

Hakan Fatih YILDIRIM

Hi all,
Ý am working aboot WCF. and i have some problems.
I created 2 interfaces containing [ServiceContract] attribute at the
top of them.and i want to create two classes implementing these
interfaces.One class implements one interface the other one implements
the other interface.The classes have different imstancecontextMode and
different bindingtypes.So how can i include two different services to
the service's configuration file .(this issue is not about using one
more endpoint in a WCF service.using two servis contract and two class
in WCF library)


Best Regards
Hakan Fatih YILDIRIM
MCP
 
Hakan,

Well, you are going to have your <services> element in the config file,
all you have to do is add one more <service> element with the address,
binding, and contract you want to expose.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi all,
Ý am working aboot WCF. and i have some problems.
I created 2 interfaces containing [ServiceContract] attribute at the
top of them.and i want to create two classes implementing these
interfaces.One class implements one interface the other one implements
the other interface.The classes have different imstancecontextMode and
different bindingtypes.So how can i include two different services to
the service's configuration file .(this issue is not about using one
more endpoint in a WCF service.using two servis contract and two class
in WCF library)


Best Regards
Hakan Fatih YILDIRIM
MCP
 
thanks for your reply.But it doesn't work.although i gave the address
of the service.in exception,"there is no configuration file or adress
for [second servisname] ". but with one service it has no problem.

Best Regards

Hakan Fath YILDIRIM
 
Well, you probably are not setting up your config file correctly.

Can you show what you have for the config file that works, and the one
that doesn't work?
 
again,many thanks for your speed replies.it is so urgent for me. i
mean that for only one single service it has no problem.but if i
include the second service in <services> tags.the exception is thrown.
 
Hakan,

And you need to post the config files so that we can make sure you are
setting them up correctly.

Also, are you setting up two instances of ServiceHost?
 
yes i didn't use multiple inheretace. i used two class nad two
instance in the WCF library
 
And are you going to post the config file for the services? I've asked
about three-four times now.
 
Hi again,


This is my confi.file

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="PerCall.service1">
<endpoint contract="PerCall.IPerCall" binding="basicHttpBinding"/>
</service>
<service name="Singtetone.service1">
<endpoint contract="Singtetone.ISingletone"
binding="wsDualHttpBinding"/>
</service>
</services>
</system.serviceModel>
</configuration>

and enpoints defined in here for each :

(For percall instance):

namespace PerCallHoster
{

internal class MyServiceHost
{
internal static ServiceHost myServiceHost = null;

internal static void StartService()
{
//Consider putting the baseAddress in the configuration
system
//and getting it here with AppSettings
Uri baseAddress = new Uri("http://localhost:8080/
percall");

//Instantiate new ServiceHost
myServiceHost = new ServiceHost(typeof(PerCall.PerCall1),
baseAddress);

//Open myServiceHost
myServiceHost.Open();
}

internal static void StopService()
{
//Call StopService from your shutdown logic (i.e. dispose
method)
if (myServiceHost.State != CommunicationState.Closed)
myServiceHost.Close();
}
}
}




(for Singletone instance) :

namespace SingleToneHoster
{

internal class MyServiceHost
{
internal static ServiceHost myServiceHost = null;

internal static void StartService()
{
//Consider putting the baseAddress in the configuration
system
//and getting it here with AppSettings
Uri baseAddress = new Uri("http://localhost:8080/
singletone");

//Instantiate new ServiceHost
myServiceHost = new
ServiceHost(typeof(Singtetone.ISingletone), baseAddress);

//Open myServiceHost
myServiceHost.Open();
}

internal static void StopService()
{
//Call StopService from your shutdown logic (i.e. dispose
method)
if (myServiceHost.State != CommunicationState.Closed)
myServiceHost.Close();
}
}
}



Although i defined the endpoints for each , i got this error
message :

Service 'PerCall.PerCall1' 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 file, or because no endpoints
were defined in the service element





Best Regards,
Hakan Fatih YILDIRIM
MCP
 
hi Nicholas,

Thanks for your efforts and faster replies. i solved the problem the
problem is simple and basic. i don't know that issue: service name =
<service namespace>.<service class> . i gave a simple name for this.
so it didn't work.

Best Regards
Hakan Fatih YILDIRIM
MCP
 
Back
Top