Interfaces/SOAP Web Service

From J Wiki
Jump to: navigation, search

We will show how to make J component available as a web service and consume it with a .NET client here, as well as a [[../Mac SOAP Client|Mac SOAP Client]] or J [[../SOAP Call|SOAP Call]].

Exposing J Service

Here we will see how to expose J component as a SOAP web service without writing any code, just configuring Windows Component Services.

Creating COM+ Application

Here we will expose J.dll as a COM+ application. To learn more about various selection user the [?] title button and point the mouse to the option of interest.


COM+ Application-Container

See also Creating a New COM+ Application, MSDN
  • Launch Component Services from Administrative Tools
  • Locate Component Services / Computers / My Computer / COM+ Applications
  • Right-click COM+ Applications, New / Application
  • In the wizard, select Next, Create Empty Application
  • Give it a name JApp
  • Leave Application Type as Server Application
  • Select Next, Next, Finish

J Component

See also Installing New Components, MSDN
  • Under JApp, right-click Components, select New Component
  • Select Next,
    • select Import... to choose registered JDLLServer.3, or
    • select Install new component and choose j.dll as a file
  • Select Next, Finish

Now JApp is ready to be consumed as a COM+ component.

SOAP Service

See also Creating XML Web Services (COM+), MSDN
  • Right-click JApp, select Properties
  • In Activation tab, check [X] Uses SOAP
  • In SOAP VRoot, give it a name, e.g. JApp

Navigate to http://localhost/JApp/ so see the wsdl interface of JDLLServer component.

Consuming J Service

Now we will create some client applications to consume the SOAP service.

.NET Web Service Client


Adding Web Reference

  • In Visual Studio, select File / New / Project
  • Visual C#, Console Application, select location and name JSoapClient, click OK
  • From menu, select Project / Add Web Reference
  • Paste http://localhost/JApp/ into URL, select Go, select JDLLServer...
  • In Web reference name, enter Local_JApp, click Add Reference

To verify, in Solution Explorer, under Web References, double-click Local_JApp to see the interfaces in Object Browser. The JDLLServerClassService is the one we are going to work with. There are other interfaces to do async calls, etc.

Calling Web Service

  • At the top of the Program.cs source enter using reference, intellisense is helping here
using JSoapClient.Local_JApp;
  • The web service must be disposed after use, so we create it

with using construct or must call .Dispose() safely

using (JDLLServerClassService jsvc = new JDLLServerClassService()) {
    ...  // the code
  • Now let's do some J calls. In Object Browser, method DoR has signature

    public int DoR(string input, out object v), so we have

    object result;
    jsvc.DoR("i.2 3", out result);
    Console.WriteLine("   i.2 3\n{0}", result);
Now run it and see the result
   i.2 3

0 1 2
3 4 5

  • If we define a name,
    jsvc.Do("a=: i.2 3");
    jsvc.DoR("+/ a", out result);
    Console.WriteLine("   +/ a\n{0}", result);
we will lose its definition
   +/ a

+/ a

  • This is because the [[../SOAP Web Service/Details|Web Service]] is activated in the SingleCall mode.

To change that open C:\WINDOWS\system32\Com\SOAPVRoots\JApp\Web.config and change <wellknown mode="SingleCall" to "Singleton", and save it.

  • Now the same construct will retain the name definition
   +/ a

3 5 7

Java Web Services Client

Since J component is exposed as a web service it would be possible to consume it from different machines using any language that can call SOAP web services, or even just can make an HTTP request.

We will next show how to access J web service using [[../Mac SOAP Client|Mac SOAP Client]]. Also it can be accessed with Java EE features.

See Also