JBuilder9 access .NET builds WebService (2)

zhaozj2021-02-16  62

Remote SOAP Access

The client's access is completed by the Java program and makes full use of some of the JBuilder9 to complete the interface work, which is only responsible for the implementation of business logic.

With the JBuilder9 tool, you can generate some interface files ("File" - Select the Web Service tab and select "Import A Web Service"). The most important two file names are: (. NET Provides the file name) Locator. Java and (file name provided by .NET) SOAP. Java. (This two files are Service1Locator. Java and Service1Soap. Java in Service1Locator. Java and Service1soap. Java. Java and Service1soap. Java

Service1Locator. Java completes an addressing feature, service1soap. Java completes the functionality of the interface access.

The code for service1soap. Java is as follows:

Public Interface Service1soap Extends Java.rmi.Remote {

Public Java.lang.String HelloWorld () throws java.rmi.remoteexception;

Public Org.Tempuri.ArrayOfanyType AddVal (INT I, INT J) THROWS JAVA.RMI.RemoteException;

Public org.tempuri.myfields Testfields (INT i) throws java.rmi.remoteexception;

Public Org.tempuri.MyObject Test (INT I) THROWS JAVA.RMI.RemoteException;

Public org.tempuri._test2response_test22ult test2 () throws java.rmi.RemoteException;

Public org.tempuri._testDataSetResponse_testDataSetResult TestDataSet () THROWS JAVA.RMI.RemoteException;

Public org.tempuri.myObject_hhf returnMyobj (INT i) throws java.rmi.RemoteException;

}

The excuses that are displayed are displayed.

Then we can go. Net builds Web Service for access. The test code is as follows:

Service1locator SL = New Service1Locator ();

Service1soap ss;

Try {

SS = sl.getService1SoAP ();

ArrayList AL1;

Object obj [];

Object obj1 [];

// Access the interface that returns a string

System.out.println (ss. HelloWorld ());

// Access method interface

System.out.println (SS. AddVal (1, 2));

// Access one-dimensional array interface

INT i [] = ss. ReturnInTarr (). Get_int ();

For (int J = 0; j

System.out.println (i [j]);

}

// Access a multi-dimensional number of interfaces

ArrayOfanyType Aoat = ss. Returnarrs ();

ArrayOfanyType AO;

Obj = aoat.getanytype ();

For (int J = 0; j

AO = (arrayofanytype) OBJ [J];

For (int K = 0; k

System.out.println ("(" J "," K ") =" AO.GETANYTYPE (K));

}

}

// Access Return Object Interface

MyObject_hhf myobj = ss.returnmyobj (10);

System.out.println ("M_ICOLCOUNT () =" myobj.getm_icolcount ());

System.out.println ("i =" myobj.geti ());

System.out.println ("getm_irowcount =" myobj.getm_irowcount ());

ArrayOfanyType Aot = myobj.getaryobj ();

Object [] OOO = AOT.GETANYTYPE ();

System.out.println ("array:");

For (int i = 0; i

System.out.println (OOO [i]);

}

} catch (exception e) {

System.out.print ("Error:" E.GetMessage ());

}

Second, the explanation

The above code is tested in JBuilder9, through this test, recognize such a few questions:

1. You cannot return to the multidimensional array. For example, a 2-dimensional or 3D array. However, multiple dimensional groups can be returned by indirect methods. As shown in the code above, a one-dimensional array can be constructed, and then each element consists of an additional array.

2. You cannot return to the record set directly. However, it is also possible to pass the method, such as an interface of the object, such as the object of the object, can be packaged into an object, but the internal method of the object cannot be accessed.

3. Try to use visual tools like JBuilder, because of the cumbersome work of generating interface files, Jubilder can do well. This greatly facilitates our work. Developers can focus on the implementation of business logic.

转载请注明原文地址:https://www.9cbs.com/read-22295.html

New Post(0)