Remoting client and server segment object inconsistent Test

Source: Internet
Author: User

Although remoting has been around for many years, some of our projects are still using remoting. Some colleagues said that after one of my remoting Server versions was upgraded, one of the parameters in the method is a class object, but some fields are added to this object. However, because the client has not been upgraded, it is still called using the old object. Is there any problem. After a simple test, I found that there was no problem and I could call each other.

Three cases are tested:

1. The client class object has fewer fields than the server.

2. The client class object has more fields than the server.

3. The client class object is named the same as the server object.

Finally, it is proved that the first and second cases are okay. In the third case, if the object namespace is the same as the Assembly name, there is no problem (the class library has no signature ).

The test project is as follows:

 

Common is a public class library and interface reservation.

Commonii is a file that contains the same content as common. The naming controls and generated class libraries are the same.

Payserver is the remoting server that references common and payservicehandler.

Payservicehandler is a real request object for processing the remoting server, referencing the common.

Remotingclient is the remoting client that references common (commonii will be referenced in subsequent tests ).

 

Payserver code:

 

Static void main (string [] ARGs)

{

Int Port = 7721;

String objecturi = "payserver ";

 

Tcpserverchannel tcpchannel = new tcpserverchannel (port );

Remotingconfiguration. registerwellknownservicetype (typeof (payservice), objecturi, wellknownobjectmode. singlecall );

 

Console. writeline ("service started ...");

Console. readkey ();

}

Remotingclient code:

 

Static void main (string [] ARGs)

{

Int Port = 7721;

String objecturi = "payserver ";

String uri = "TCP: // 127.0.0.1:" + port + "/" + objecturi;

Ipayservice service = (ipayservice) activator. GetObject (typeof (ipayservice), Uri );

Payinfo info = new payinfo ();

// Info. Account = 230.5 m;

Info. payid = 1;

Info. providerid = 20;

Info. otherint = 10;

Info. otherstr = "ABC ";

Info. Consumer = new consumerinfo () {consumerid = 10,

// Consumername = "Lawson ",

Consumerphone = "123456 "};

String value = service. getpayaccount (Info );

 

Console. writeline (value );

Console. readkey ();

}

When the client has fewer account fields, the server normally receives the request, and the account value is 0. When the client's consumerinfo object contains fewer consumernames, the server normally receives the request, and the value of consumername is null.

When the client has multiple otherint and otherstr values, the server normally receives the request without the values of these two fields.

When the client references commonii, the internal class namespace of commonii is the same as that of common, and the class library of commonii is also generated as common. dll. The server normally accepts the request and processes it normally.

When I add a signature to the original Common Assembly and use mysnk. pfx to sign the Assembly, no matter whether the common or commonii is referenced by the client, a message indicating that the access type is inaccessible due to security restrictions is displayed... You cannot find a suitable solution by searching through the network.

 

/Files/Lawson/remotingobjecttests2011.12.10.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.