In terms of architecture, WebService has five layers:
1. Http Transmission Channel
2. XML data format
3. Soap Encapsulation Format
4. Description of WSDL
5. UDDI
From the transmission mode: The transfer protocol for Web Service and remoting is different. Web Service is HTTP and can penetrate the firewall.
Remoting transmits data through socket.
In terms of Operating Principle:
1. Web Service. First, the WSDL of the client from the server to the WebService, and the client claims a proxy class)
This proxy class is responsible for request and response with the WebService server. when a data (in XML format) is encapsulated into a data stream in soap format and sent to the server, a process object is generated and the soap packet that receives the request is parsed, then, the transaction is processed. After the processing is completed, the computation result is packaged with soap, and then the package is used as a proxy class sent to the client as a response. Similarly, this proxy class also parses the soap package and then performs subsequent operations.
2..net remoting. net remoting is a technology developed on the basis of DCOM. Its main purpose is to achieve cross-platform, cross-language, and penetration of Enterprise Firewall, which is also its basic feature, different from WebService, WebService supports HTTP and TCP channels. It can not only transmit soap packets in XML format, but also transmit binary streams in the traditional sense, this makes it more efficient and flexible. In addition, it does not depend on IIS. Users can develop and deploy their own host servers (dispose). Therefore, WebService is actually used in these aspects. A special case of net remoting.
From the characteristics of bothSee:
WebService features:
Platform independence (platform-independent), cross-language (any language that supports XML), and enterprise firewall penetration, but its disadvantage is also obvious, that is, the deployment of a Web server; and the speed is relatively slow;
. Net remoting features:
The advantage is that users can use both TCP-based binary stream communication and HTTP-based soap-based communication.
The efficiency is much higher than that of WebService, but its disadvantages are also obvious.. Net remoting can only be applied under the. NET Framework of Ms.
In terms of performance, the efficiency of remoting is very similar to that of traditional DCOM and COM +!
Advantages and disadvantages of remoting
Advantages:
1. allows us to conduct distributed development
2. Fast TCP channel remoting
3. Although it is remote, It is very close to the local call object.
4. The object state can be maintained.
5. There are no application restrictions. You can use the console, winform, IIS, and Windows Services to host remote objects.
Disadvantages:
1. Non-standard applications have platform restrictions
2. If you leave IIS, you need to have your own security mechanism.
Remoting Functions:
Remoting provides the following functions:
1) communication between different processes.
2) communication between objects of different processes in different application domains (appdomain) (multiple communication protocols can be used ).
The remoting concepts commonly used include:
Remoting channel: this refers to the communication protocol between the client and the server. For example, we can use TCP or HTTP.
Serializer: the format used for data transmission. For example, we can use binary or soap to transmit XML data.
. Net tries to simplify the programming of these concepts, so the protocol and format described above can be switched by changing the configuration file. This is also a problem that programmers do not have to worry about. For example, the content of a typical client configuration file is:
<Configuration>
<System. runtime. remoting>
<Application>
<Channels>
<Channel ref = "HTTP" clientconnectionlimit = "200">
<Clientproviders>
<Formatter ref = "binary">
</Clientproviders>
</Channel>
</Channels>
</Application>
</System. runtime. remoting>
</Configuration>
For example:
Configuration File example-Server
<Configuration>
<System. runtime. remoting>
<Application>
<Service>
<Wellknown mode = "Singleton" objecturi = "sayhello"
Type = "remotingsamples. helloserver, General"/>
</Service>
<Channels>
<Channel port = "8086" ref = "HTTP"/>
</Channels>
</Application>
</System. runtime. remoting>
</Configuration>
Configuration File example-Client
<Configuration>
<System. runtime. remoting>
<Application>
<Client>
<Wellknown url = "http: // localhost: 8086/sayhello"
Type = "remotingsamples. helloserver, General"/>
</Client>
<Channels>
<Channel port = "0" ref = "HTTP"/>
</Channels>
</Application>
</System. runtime. remoting>
</Configuration>
Key terms:
-- Remote object: 1. operate a remote object. If the object runs remotely, the client sends a message to the object. Marshalbyrefobject
2. Pass the remote object to the local device, or send the local object to the local device. Operate on the replica [serializable] Or iserializable
-- Activation Method: 1. server activation (wellknown) Singleton singlecall 2. Client Activation
---- Channel (channels) 1. A remote object uses a channel to send and receive messages. 1.1 The server selects a channel to listen for requests. 1.2 The client selects a channel to communicate with the server. 2. remoting provides the built-in channel 2.1tcp and HTTP channel 2.2. You can also write your own channel.
Development procedure(In three steps)
1. Create a remote object 2. Create an application as a "host" to receive client requests 3. Create a client to call a remote object
Step 1: Create a remote object
Inherit System. externalbyrefobject
Public class helloserver: marshalbyrefobject
{
......
}
Step 2: Create a Host application
Registration Channel
Built-in channels: TCP and HTTP
Register the remote object activated by the server
(Wellknown)
Singleton, singlecall
URL
Run the Host Program
Step 3: Create a client program
Registration Channel
Built-in channels: TCP and HTTP
Get object proxy Based on URL
Use a proxy to call a remote object
PASS Parameters:
1. Pass the simple type int, doulbe, String, Enum ...... 2. Pass serializable arraylist, hashtable, dataset ......
3. pass custom type [serializable]
Finally,Common use of the two:
Generally, if your product is used in a LAN, you can use. Net remoting.
If remote access is provided, Web Service is used.
Of course, it is not absolute. You can use it as needed.