Server-to-Server Remoting
From: Bob Pulgino (bob_at_digitalmediums.com)
Date: 04/15/04
- Next message: kackson: "A basic question on remoting."
- Previous message: Sandeep: "sending word document object over remoting"
- Next in thread: Allen Anderson: "Re: Server-to-Server Remoting"
- Reply: Allen Anderson: "Re: Server-to-Server Remoting"
- Messages sorted by: [ date ] [ thread ]
Date: 15 Apr 2004 02:12:00 -0700
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: kackson: "A basic question on remoting."
- Previous message: Sandeep: "sending word document object over remoting"
- Next in thread: Allen Anderson: "Re: Server-to-Server Remoting"
- Reply: Allen Anderson: "Re: Server-to-Server Remoting"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|