[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Calling a server with a binary and a soap formatter.

aniketpalkar

9/30/2004 3:19:00 PM

Hello,
I am facing a problem with .net remoting. I have one client that
needs to call two servers.
Server 1:- Publishes a server activated object with a http channel
and uses a binary formatter.
Server 2:- Publishes a server activated object with a http channel
and uses a soap formatter.
When I register two channels for contacting these two on client side
that part works fine. However I am not able to make calls on these two
servers. Activator.GetObject goes through correctly. However only the
call to the server which uses the formatter corresponding to the first
channel registered goes through, the other call fails with a
serialization error.

code is similar to

HttpChannel httpChnl1 = new HttpChannel(props,
binaryClientSinkProvider, binaryServerSinkProvider);

HttpChannel httpChnl2 = new HttpChannel(props, soapClientSinkProvider,
soapServerSinkProvider);

ChannelServices.RegisterChannel(httpChnl1);
ChannelServices.RegisterChannel(httpChnl2);

IMyInterface obj1 = (IMyInterface)Activator.GetObject(typeof(IMyInterface
), BinaryServer1Url);

obj1.Call(1); // goes through fine.

IMyInterface obj2 = (IMyInterface)Activator.GetObject(typeof(IMyInterface
), soapServer2Url);

obj2.Call(2); // fails with a serialization error. From the error it
seems like it is sending this as binary serialized data, while the
server is listening with soap.

If I make the second server tcp/soap instead of http/soap it works
fine. However if I make the first server tcp/binary as well again I
get the same problem.

How do I make call succesfully on these two servers? I can't control
what protocol or formatter the server will support. I must make a call
on them irrespective from my client.

Regards,
AP
5 Answers

Steve L

10/1/2004 1:28:00 AM

0

How are you hosting these servers?

Are they console or IIS-based or services? IIS-based will only use HTTP.

Also, are the sinks/sinkproviders listed below custom sinks? In which
case, one might need to review the code there


aniketpalkar@hotmail.com (AP) wrote in
news:fa0c6936.0409300718.176c221b@posting.google.com:

> Hello,
> I am facing a problem with .net remoting. I have one client that
> needs to call two servers.
> Server 1:- Publishes a server activated object with a http channel
> and uses a binary formatter.
> Server 2:- Publishes a server activated object with a http channel
> and uses a soap formatter.
> When I register two channels for contacting these two on client side
> that part works fine. However I am not able to make calls on these two
> servers. Activator.GetObject goes through correctly. However only the
> call to the server which uses the formatter corresponding to the first
> channel registered goes through, the other call fails with a
> serialization error.
>
> code is similar to
>
> HttpChannel httpChnl1 = new HttpChannel(props,
> binaryClientSinkProvider, binaryServerSinkProvider);
>
> HttpChannel httpChnl2 = new HttpChannel(props, soapClientSinkProvider,
> soapServerSinkProvider);
>
> ChannelServices.RegisterChannel(httpChnl1);
> ChannelServices.RegisterChannel(httpChnl2);
>
> IMyInterface obj1 =
> (IMyInterface)Activator.GetObject(typeof(IMyInterface ),
> BinaryServer1Url);
>
> obj1.Call(1); // goes through fine.
>
> IMyInterface obj2 =
> (IMyInterface)Activator.GetObject(typeof(IMyInterface ),
> soapServer2Url);
>
> obj2.Call(2); // fails with a serialization error. From the error it
> seems like it is sending this as binary serialized data, while the
> server is listening with soap.
>
> If I make the second server tcp/soap instead of http/soap it works
> fine. However if I make the first server tcp/binary as well again I
> get the same problem.
>
> How do I make call succesfully on these two servers? I can't control
> what protocol or formatter the server will support. I must make a call
> on them irrespective from my client.
>
> Regards,
> AP
>

aniketpalkar

10/1/2004 11:27:00 AM

0

I am hosting the servers in a console app for now.(Eventually will be
a windows service.) No custom sinks are being used.

Steve L

10/1/2004 11:06:00 PM

0

Take a look at the aspnet quickstart sample

http://samples.gotdotnet.com/quickstart/aspplus/default....
2fquickstart%2fhowto%2fdoc%2fRemoting%2fsingleton.aspx

This illustrates the basic principle of calling the server on two different
channels. Hope it helps

aacool

aniketpalkar@hotmail.com (AP) wrote in news:fa0c6936.0410010327.206a8913
@posting.google.com:

> I am hosting the servers in a console app for now.(Eventually will be
> a windows service.) No custom sinks are being used.

Steve L

10/2/2004 12:23:00 AM

0

Here is a working client that calls two servers - server1 is a tcp/binary
server, server2 is a http/soap server.

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels.Http;
using General;

namespace tcpclient
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class tcpclient
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("Connecting to tcp server");
TcpClientChannel chnl = new TcpClientChannel
();//System.Runtime.Remoting.Channels.Tcp.
ChannelServices.RegisterChannel(chnl);
RemotingConfiguration.RegisterWellKnownClientType(
typeof
(General.ICustomerManager),"tcp://localhost:1300/TCPCustomerMgr");
General.ICustomerManager custMgr = (ICustomerManager)
Activator.GetObject(typeof
(General.ICustomerManager),"tcp://localhost:1300/TCPCustomerMgr");
Customer cust = custMgr.getCustomer(124);
Console.WriteLine(cust.cust_id.ToString()+" customer
received");
cust.BirthDate = new DateTime(1955,3,3);
int age = custMgr.getAge(cust);

Console.WriteLine("Connecting to http server");
System.Runtime.Remoting.Channels.Http.HttpChannel httpchnl
= new HttpChannel();
ChannelServices.RegisterChannel(httpchnl);
RemotingConfiguration.RegisterWellKnownClientType(
typeof
(BasicServer.CustomerMgr),"http://localhost/BasicServer");
BasicServer.CustomerMgr httpCustMgr = new
BasicServer.CustomerMgr();
//Customer cust2 = httpCustMgr.getCustomer(1400);
Console.ReadLine();
}
}
}


aacool <a@b.c> wrote in news:Xns9575B84DA5DB4aacool@24.94.170.87:

> Take a look at the aspnet quickstart sample
>
> http://samples.gotdotnet.com/quickstart/aspplus/default....
> 2fquickstart%2fhowto%2fdoc%2fRemoting%2fsingleton.aspx
>
> This illustrates the basic principle of calling the server on two
> different channels. Hope it helps
>
> aacool
>
> aniketpalkar@hotmail.com (AP) wrote in
> news:fa0c6936.0410010327.206a8913 @posting.google.com:
>
>> I am hosting the servers in a console app for now.(Eventually will be
>> a windows service.) No custom sinks are being used.
>
>

aniketpalkar

10/4/2004 6:12:00 AM

0

Thanks for taking the time to answer this. However this does not solve
my problem. My problem is when I try to connect to two servers with
the same protocol but diffrent formatters. i.e. I have a problem if
a) Server 1:- tcp/binary and Server2:- tcp/soap or
b) Server 1:- http/binary and Server2:- http/soap
In this case what happens is that when I try to connect to server2 it
still uses a binary formatter, not a soap one.
Other combinations like Server1:- tcp/binary Server2:- tcp/soap
etc,(infact all others except when case is a or b above) work fine. It
is only when the 2 server are using the same protocol but diferent
formatters that the problem comes up.
However I have now figured out how to do this. The solution seems to
be writing a custom client formatter sink provider. I got this from
http://www.thecodeproject.com/csharp/abstract_client_for...

Regards,
AP