How to Access .NET Objects as Singletons Hosted in IIS |
|
This article will help you get started if you are having problems accessing your Singleton object hosted in IIS from your Java client.
As an example, the Accessing .NET Components Hosted in Internet Information Server (IIS) from Java example will be converted to a Singleton to be accessed by the Java client. The first step is to verify that this example works - please follow the instructions provided by the link. Next, to change the example to a Singleton follow the steps below:
- Modify web.config located in J-Integra\.NET\examples\java_iis\HelloWorldServer to replace:
<service>
<activated type="HelloWorld.HelloWorldClass, HelloWorld"/>
</service>
with: <service>
<wellknown mode="Singleton" objectUri="HelloWorld.HelloWorldClass.soap" type="HelloWorld.HelloWorldClass, HelloWorld"/>
</service>
This changes the type of remoting from Client Activated Objects (CAO's) to Server Activated Objects (SAO's). A Singleton in .NET is a type of SAO.
- In Janetor, change the Activation Mode to Web Services and the Channel Format to SOAP. Here is a screenshot of the changes to make in Janetor:
- When accessing SAO's from Java, Ja.NET forms the URL to look for the hosted object as follows:
http://[URI from Janetor]/[namespace].[class name].soap
Given the settings in Janetor (see screenshot) and that the namespace is HelloWorld and the class to access is HelloWorldClass, the URL will be:
http://localhost/HelloWorld/HelloWorld.HelloWorldClass.soap
This must be reflected in the web.config file - this is the reason why HelloWorld.HelloWorldClass.soap was entered for the objectUri attribute. In general, for Ja.NET to access the SAO, the objectUri attribute in web.config must be of the form:
[namespace].[class name].soap
That is all there is to it! Try running the client again, and you should get the same results. Both server and client code stays the same - you do not need to modify any code. Also, note that IIS does not need to be restarted after the modifications to web.config.