Re: Server-to-Server Remoting
From: Allen Anderson (allen_at_sparkysystems.com)
Date: 04/15/04
- Next message: Allen Anderson: "Re: basic remtoing question"
- Previous message: Allen Anderson: "Re: A basic question on remoting."
- In reply to: Bob Pulgino: "Server-to-Server Remoting"
- Next in thread: Jon Lipp: "Re: Server-to-Server Remoting"
- Reply: Jon Lipp: "Re: Server-to-Server Remoting"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 15 Apr 2004 11:10:24 -0600
Your asking a lot of questions here so let me put down some general
notes based on what I've seen looking through your sample and
comments. You can't send an object from server b that you got at
server a and send it to client c. In other words, you can't middleman
an object.
the register channel code to get from server a to server b is
unncessary as your making a client call and there is already a channel
registered for the application because its serving another object.
your code that connects to server b from server a will be identical
except for the channel registrations.
to get around the problem with the type already being known locally,
stop using configuration files. I realize that most people recommend
using configuration files for everything, but this is a good time not
to. If you simply have your abstract class available and use
activator to get the type that YOU want to create at any given time,
then you will know that your are getting the type you want based on
the URI you use with activator.
Allen Anderson
http://www.glacialcomponents.com
mailto: allen@put my website url here.com
On 15 Apr 2004 02:12:00 -0700, bob@digitalmediums.com (Bob Pulgino)
wrote:
>Here's my situation:
>
>I have a classic client/server application that involves multiple
>users of a WinForms application connecting to a central remoted .NET
>component for business logic and database services. This has been
>working fine for a few months now. In fact, it is in production for
>two organizations; each organization has its own group of WinForms-app
>users and a unique server with the .NET component running to provide
>the users within that organization with services for the
>organization's unique database.
>
>I am trying to implement a new feature for the next release of this
>system that requires the ability to pass information from one
>organization's service component to another's; i.e., I need to be able
>to call a method on one specific instance of my remoted .NET component
>(for organization "A") from within another method of a different
>instance (server) of that same component (for organization "B").
>
>My problem is that I can't figure out how to register and instantiate
>the proxy for the remote component class from within the local
>instance of the same class - when I use the same code I used to
>connect from the WinForm application, the framework throws an "Unknown
>remoting error" exception the first time I reference the proxy.
>
>Here are the implementation details: I define an abstract base class
>called BaseDataService that is used by the client as the interface for
>the service component, which is a subclass of BaseDataService called
>MaxDataService.
>
>Here is the code I use in the console app that hosts the service
>component:
>
> RemotingConfiguration.Configure("MaxDataServiceConsole.exe.config")
>
>(...from MaxDataServiceConsole.exe.config:)
> <channels>
> <channel ref="http" port="1234">
> <serverProviders>
> <formatter ref="binary" />
> </serverProviders>
> </channel>
> </channels>
> <service>
> <wellknown
> mode="Singleton"
> type="DataServices.MaxDataService, MaxDataService"
> objectUri="MaxDataService.rem"
> />
> </service>
>
>
>Here is the code I used to connect to the service component from
>within the WinForms app:
>
> Private Shared mDataService As BaseDataService
> ...
> Dim channel As HttpChannel
> channel = New HttpChannel(Nothing, New
>BinaryClientFormatterSinkProvider(), Nothing)
> ChannelServices.RegisterChannel(channel)
> Dim serviceUrl as String =
>"http://localhost:1234/MaxDataService.rem"
> mDataService = CType(Activator.GetObject(GetType(BaseDataService),
>serviceUrl), BaseDataService)
>
>
>As I said above, this all works fine... the problem arose when I added
>a method to the MaxDataService component that used the following code:
>
> ' Get the URL to the vendor's service component
>[1] Dim mdsURL As String =
>Me.GetDataServiceURL(soldevent.VendorMemberID)
>
> ' Obtain connection to the vendor's service component...
>[2] Dim mds As MaxDataService = CType(Activator.GetObject( _
> GetType(MaxDataService), mdsURL), MaxDataService)
>
> ' Test the connection...
>[3] Dim test As String = mds.Greetings
>
>
>Tracing through this code, I know that we have a valid URL after line
>[1], and we have a non-null value for 'mds' after line [2] (mds has a
>value of type transparentProxy), but when we try to invoke the simple
>test member named Greetings in line [3], the "unknown remoting error"
>exception is thrown.
>
>
>Originally, I used the two lines of code shown below right above line
>[2]:
>
> Dim channel As HttpChannel = New HttpChannel(Nothing, New
>BinaryClientFormatterSinkProvider(), Nothing)
> ChannelServices.RegisterChannel(channel)
>
>...but I had to remove them because the RegisterChannel call threw an
>exception stating that the channel was already registered.
>
>
>Just out of curiosity, I tried the line of code shown below instead of
>line [2] to see what would happen:
>
> RemotingConfiguration.RegisterWellKnownClientType(GetType(MaxDataService),
>mdsURL)
>
>...but this line threw an exception with the following message:
>
>Attempt to redirect activation for type 'DataServices.MaxDataService,
>MaxDataService'. This is not allowed since either a well-known
>service type has already been registered with that type or that type
>has been registered has a activated service type.
>
>I'm assuming my problem is that I'm trying to register a given type as
>a remoted type when that type is already known locally (?), but I
>can't believe that I'm the only one who ever wanted to do such a thing
>- there has to be a way to connect two components of the same type
>through .NET remoting (I hope?).
>
>Can anyone help?
- Next message: Allen Anderson: "Re: basic remtoing question"
- Previous message: Allen Anderson: "Re: A basic question on remoting."
- In reply to: Bob Pulgino: "Server-to-Server Remoting"
- Next in thread: Jon Lipp: "Re: Server-to-Server Remoting"
- Reply: Jon Lipp: "Re: Server-to-Server Remoting"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|