Windows Vista Forums

WCF: How to reference a service that runs in the same process?

  1. #1


    Steve B. Guest

    WCF: How to reference a service that runs in the same process?

    Hi,

    I'm building a service that can act both client and server (two servers can
    communicate each others).

    How can I set my project in order to create the service reference ?

    thanks,
    Steve


      My System SpecsSystem Spec

  2. #2


    Arkady Frenkel Guest

    Re: How to reference a service that runs in the same process?

    If you mean, that you want to communicate from one service with another, you
    can use proxy exactly as client or create channel to second service's entry
    point directly :
    channelFactory = new ChannelFactory<YouSecondServiceInterface>(binding,
    address);

    YouSecondServiceInterface channel = channelFactory.CreateChannel();

    Arkady

    "Steve B." <steve_beauge@com.msn_swap_msn_and_com> wrote in message
    news:e0JW4T18GHA.4304@TK2MSFTNGP03.phx.gbl...
    > Hi,
    >
    > I'm building a service that can act both client and server (two servers
    > can communicate each others).
    >
    > How can I set my project in order to create the service reference ?
    >
    > thanks,
    > Steve
    >



      My System SpecsSystem Spec

  3. #3


    Steve B. Guest

    Re: How to reference a service that runs in the same process?

    Let's expose the scenario...

    I want to build a service that runs on multiple serveurs. These services can
    send data to other instances of the service on other computer.

    The sent data is selected by an administrator in a windows app.

    We have :

    Admin computer : run a windows app which is client of "SourceService"
    Server A : run a host which is client of "DestinationService" and host
    "DestinationService" and "SourceService"
    Server B : run a host which is client of "DestinationService" and host
    "DestinationService" and "SourceService"

    The source service have a method like : SendData(Data myData, string
    remoteServer)
    The destination service have a methode like : ReceiveData(Data myDate);

    Inside this method, I have something like this:

    string remote = BuildUri(uriFormat, remoteserver); // build the correct
    remote uri

    DestinationServiceClient proxy = new DestinationServiceClient(remote);

    proxy.ReceiveData(Data myData);


    However, the last line "proxy.ReveiveData" throw an exception 400: bad
    request.

    I also try this code :
    IDestination destProxy = ChannelFactory<IDestination>.CreateChannel(

    new WSHttpBinding(),

    new EndpointAddress(remoteUri)

    );

    destProxy.ReceiveData(myData);



    But I get the same behaviour...

    "Arkady Frenkel" <arkadyf@hotmailxdotx.com> a écrit dans le message de news:
    OSjzAO28GHA.4996@TK2MSFTNGP03.phx.gbl...
    > If you mean, that you want to communicate from one service with another,
    > you can use proxy exactly as client or create channel to second service's
    > entry point directly :
    > channelFactory = new ChannelFactory<YouSecondServiceInterface>(binding,
    > address);
    >
    > YouSecondServiceInterface channel = channelFactory.CreateChannel();
    >
    > Arkady
    >
    > "Steve B." <steve_beauge@com.msn_swap_msn_and_com> wrote in message
    > news:e0JW4T18GHA.4304@TK2MSFTNGP03.phx.gbl...
    >> Hi,
    >>
    >> I'm building a service that can act both client and server (two servers
    >> can communicate each others).
    >>
    >> How can I set my project in order to create the service reference ?
    >>
    >> thanks,
    >> Steve
    >>

    >
    >



      My System SpecsSystem Spec

  4. #4


    Arkady Frenkel Guest

    Re: How to reference a service that runs in the same process?

    That exact scenario of router example from
    http://windowssdk.msdn.microsoft.com...97(VS.80).aspx
    I prefer second way - direct channel without proxy because both sides know
    each other in my case
    Arkady


    "Steve B." <steve_beauge@com.msn_swap_msn_and_com> wrote in message
    news:%23geTCb28GHA.4604@TK2MSFTNGP03.phx.gbl...
    > Let's expose the scenario...
    >
    > I want to build a service that runs on multiple serveurs. These services
    > can send data to other instances of the service on other computer.
    >
    > The sent data is selected by an administrator in a windows app.
    >
    > We have :
    >
    > Admin computer : run a windows app which is client of "SourceService"
    > Server A : run a host which is client of "DestinationService" and host
    > "DestinationService" and "SourceService"
    > Server B : run a host which is client of "DestinationService" and host
    > "DestinationService" and "SourceService"
    >
    > The source service have a method like : SendData(Data myData, string
    > remoteServer)
    > The destination service have a methode like : ReceiveData(Data myDate);
    >
    > Inside this method, I have something like this:
    >
    > string remote = BuildUri(uriFormat, remoteserver); // build the correct
    > remote uri
    >
    > DestinationServiceClient proxy = new DestinationServiceClient(remote);
    >
    > proxy.ReceiveData(Data myData);
    >
    >
    > However, the last line "proxy.ReveiveData" throw an exception 400: bad
    > request.
    >
    > I also try this code :
    > IDestination destProxy = ChannelFactory<IDestination>.CreateChannel(
    >
    > new WSHttpBinding(),
    >
    > new EndpointAddress(remoteUri)
    >
    > );
    >
    > destProxy.ReceiveData(myData);
    >
    >
    >
    > But I get the same behaviour...
    >
    > "Arkady Frenkel" <arkadyf@hotmailxdotx.com> a écrit dans le message de
    > news: OSjzAO28GHA.4996@TK2MSFTNGP03.phx.gbl...
    >> If you mean, that you want to communicate from one service with another,
    >> you can use proxy exactly as client or create channel to second service's
    >> entry point directly :
    >> channelFactory = new ChannelFactory<YouSecondServiceInterface>(binding,
    >> address);
    >>
    >> YouSecondServiceInterface channel = channelFactory.CreateChannel();
    >>
    >> Arkady
    >>
    >> "Steve B." <steve_beauge@com.msn_swap_msn_and_com> wrote in message
    >> news:e0JW4T18GHA.4304@TK2MSFTNGP03.phx.gbl...
    >>> Hi,
    >>>
    >>> I'm building a service that can act both client and server (two servers
    >>> can communicate each others).
    >>>
    >>> How can I set my project in order to create the service reference ?
    >>>
    >>> thanks,
    >>> Steve
    >>>

    >>
    >>

    >
    >



      My System SpecsSystem Spec

WCF: How to reference a service that runs in the same process?

Similar Threads
Thread Forum
Setting process priority so it runs when screen is locked
Hello Experts, I run some CPU intensive processes (video encoding using X264) in a command shell. Since I don't want it to affect my normal...
Vista performance & maintenance
vs2008 Add Service Reference generates Reference.cs which wont com
I have tried several times to build the simplest WCF service lib in VS2008 - out of a dozen tries, the built in tools have worked once. 1. In...
Indigo
VS2005 Add Service Reference doesn't create correct proxy security config
Hello, I am trying to create a WCF host/client combination using mixed security with UserName authentication. Everything looks good on the...
Indigo
Error when add reference of the WCF service
Hi, I am new to the WCF and i was trying to do "Hello world" sample. but i m getting error when i add the reference of my WCF service to another...
Indigo
Inconsistent results with Add Service Reference
I have a contract method that returns a generic list IList<string> Operation3(Guid myGuid); When I run Add Service Reference to a winforms...
Indigo
Returning an interface reference from a service method
Hi, I am trying to write a WCF service where one of the methods is returning an interface type. This method call however fails. If I change the...
Indigo
The option ' Add Service Reference' doesn't appears in the context menu of web projects.
Hi Why the option ' Add Service Reference' doesn't appears in the context menu of web projects? In other kinds of projects like classlibrray o...
Indigo