[Remoting-4], remoting-4
[Three activation methods for service objects]
[1] client Activation Method
[A] when an object is created, the object method is executed on the remote server.
[B] The server creates exclusive objects for each client, provides services for this client, and saves the status.
[C] return values of method execution can be obtained remotely.
[D] when using the customer activation method, the remote object is created when the new operation is called [describes when the remote object is created on the server]
[2] server activation method -- Singleton
[A] on the server side, the constructor of the service object is called only once.
[B] All subsequent requests use this object for service. ==> [Stateful] activation mode
[C] multiple clients share the status of a remote object ].
[D] using the new operator on the [client] instantly, the [server] does not create an object,
The object is created on the server only when the method of the object proxy object is called for the first time in client proxy.
==> The server creates only one service object.
[3] server activation-SingleCall
[A] objects provide services for each method call.
==> For each method call of the client, the server creates an object to serve it. After the method is executed, the object is destroyed.
[B] SingleCall cannot save the object state ==> [stateless] activation mode.
==> If you want to save the object status? ==> Solution: store the object state outside the object.
[C] using the new operator on the [client] instantly does not create an object on the [server,
The object will be created on the server only when the client proxy object calls the method.
==> Each time a method is called, the server creates a service object.
[Send the value of Remoting]
[1] The object flag must be serializable
[2] construct a factory class as a remote service object, and then block the object to be sent to the client as the return value of the process method.
[3] There is no need for Remoting. If you want to pass the remote object value to the client, what is the significance of Remoting?
[Separation of service Assembly metadata and code implementation]
How to separate the service assembly of [Host application domain, Host Appdomain] and [Client Appdomain of customer application domain?
[1] use interfaces to separate service assembly
==> Separates the metadata of the type from the implementation of the type
[Note] the client activation object cannot be created.
[A] The Activator. GetObject () method is applicable only to the server activation method.
[B] Activator. CreateInstance () method. The object as a parameter must meet two conditions. (1) inherit MBR, and (2) the server must register for this type.
[2] use an empty class to separate the service assembly
==> The service Assembly contains a small amount of code
32.16use soapsuds.exe to separate the Assembly
==> Generate an "Empty class" assembly
【SoapSuds.exe] is. net provides a tool that allows the client to input a Url of a remote object and then generate a dll Assembly file, which contains all the metadata information of the client wearing proxy,
But it does not contain any specific implementation ==> ["Empty class" assembly]
How can I use soapsuds.exe to obtain the dll file ?]
[1] after the service is started, the remote object is activated. [Note]
[A] The activation method can only be the Service Activation object [SingleCall/Singleton]
[B] uses the Http channel and the message format is SOAP format.
[C] After the dll assembly is generated, the client can access the remote object regardless of the Protocol or format used by the server. [Note]
[2] The client uses the [vs command prompt] tool to generate a service assembly using the soapsuds command.
Soapsuds {-url: schemaUrl |-types: type1, assemblyname [, serviceEndpoint] [; type2, assemblyname] [...] |-is: schemafile |-ia: assemblyfile} [options]
==> Soapsuds-url: serviceObjUrl? Wsdl-oa: assemblyname. dll]
[4] use the factory method for separation
==> A variant of interface Separation
[This method is only applicable to the client activation mode, but is similar to the server activation mode]
[Because it is a factory type, almost all methods for activating objects on the server side use Singleton]
==> Solved the problem that the client cannot be created to activate the object when the interface is used directly.