Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2007

Tip: Looking for answers? Try searching our database.

Hosting 2 WCF Service in one windows service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hakan Fatih YILDIRIM - 27 Dec 2007 20:27 GMT
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
Nicholas Paldino [.NET/C# MVP] - 27 Dec 2007 21:09 GMT
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.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

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 Fatih YILDIRIM - 27 Dec 2007 21:27 GMT
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
Nicholas Paldino [.NET/C# MVP] - 27 Dec 2007 21:37 GMT
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?

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> 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
[quoted text clipped - 3 lines]
>
> Hakan Fath YILDIRIM
Hakan Fatih YILDIRIM - 27 Dec 2007 21:40 GMT
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.
Nicholas Paldino [.NET/C# MVP] - 27 Dec 2007 22:00 GMT
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?

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> 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 Fatih YILDIRIM - 28 Dec 2007 15:16 GMT
yes i didn't use multiple inheretace. i used two class nad two
instance in the WCF library
Nicholas Paldino [.NET/C# MVP] - 29 Dec 2007 19:45 GMT
And are you going to post the config file for the services?  I've asked
about three-four times now.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> yes i didn't use multiple inheretace. i used two class nad two
> instance in the WCF library
Hakan Fatih YILDIRIM - 31 Dec 2007 07:30 GMT
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
Hakan Fatih YILDIRIM - 31 Dec 2007 08:00 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.