Axis and JAX Web Services |
Content |
|||||||||||||||
|
Introduction |
|
|
The LabVantage implementation of Axis and JAX Web Services comply with the reference implementations shown below. Choose the service with the reference implementation that meets your requirements.
LabVantage Web Service | Reference Implementation | Comments |
SapphireWS | Apache Axis | Axis is the Apache implementation, which often requires third-party dependencies. See axis.apache.org for more information. |
SapphireBasicWS | JAX-WS | JAX is part of the Oracle Java API, and supports the set of WS-I standards. See docs.oracle.com/javaee/6/tutorial/doc/bnayl.html for more information. |
LabVantage also provides a RESTful implementation. See LabVantage REST Web Services for information.
SapphireWS |
|
|
Enabling Ajax/JAX Web Services |
Before proceeding, you must make certain the Ajax/JAX Web Services are enabled. Enable them if necessary by setting the Web Services → Enable property in the Security Policy to "Yes". Save, then restart the Application Server and the LabVantage application.
Generating the WSDL and Source Files for SapphireWS |
For clarity, this section uses example directory names rather than environment variables. If you want to use variables in a script, we recommend:
Directory | Suggested Variable |
C:\ear | LIB_FOLDER |
C:\sapphirews | WDSL_FOLDER |
C:\sapphirews\gen | CLASSES_FOLDER |
In general, these are suggested guidelines for preparing your environment:
1. | Create the directory C:\ear. | |||||||||||||||||||||||||
2. | Explode labvantage.ear into C:\ear, so you have the directory structure
C:\ear\labvantage.ear with all subdirectories of the EAR beneath it (APP-INF,
labvantage.war, lib, META-INF, and sapphire.jar). This will provide access
to the JARs that are required to generate the Service Locator and stubs:
|
|||||||||||||||||||||||||
3. | Create the directory C:\sapphirews. |
Generate the WSDL file as follows:
1. | Open the SapphireWS WSDL by pointing the Web browser to this URL:
http://<hostname>:<port>/<webapp>/services/SapphireWS?wsdl where <hostname>, <port>, and <webapp> indicate relevant values for the local machine. You should see the WSDL rendered in the browser as shown in the example below: |
|
2. | Save the SapphireWS.wsdl in C:\sapphirews. |
Generate the Service Locator and stubs by running the example command shown below in C:\sapphirews (see http://ws.apache.org/axis/java/reference.html).
<path>\java.exe -classpath "C:\ear\labvantage.ear\lib\*;C:\ear\labvantage.ear\sapphire.jar" org.apache.axis.wsdl.WSDL2Java -o . -a -t -v -p .\gen SapphireWS.wsdl
where <path> is the path to java.exe (in the JDK). Also note that this example assumes the location of the exploded EAR is in C:\ear\labvantage.ear.
This command generates these Java source files in C:\sapphirews\gen:
• | ActionBlockTransport.java | • | EmpowerMessage.java | • | SapphireWSServiceLocator.java | ||
• | AttachmentTransport.java | • | PropertyListCollectionTransport.java | • | SapphireWSServiceTestCase.java | ||
• | BaseSECMessage.java | • | PropertyListTransport.java | • | SapphireWSSoapBindingStub.java | ||
• | DataSetColumnTransport.java | • | PropertyValueTransport.java | • | SDIDataTransport.java | ||
• | DataSetRowTransport.java | • | SapphireWS_PortType.java | • | SDIRequestTransport.java | ||
• | DataSetTransport.java | • | SapphireWSService.java | • | XMLMessage.java |
You can ignore this message if it is issued: "Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled."
SapphireWS Web Service Operations |
These operations provide generic calls to the LabVantage Java Public API (such as getSQLDataSet and processAction). However, they use LabVantage-specific XML structures to send/receive data to/from the Web Service. These methods allow direct object interaction with SOAP languages such as .NET. All parameters are "String" data type.
Operation | Description | |||||||||||||||||||||||||||||
checkConnection | Determines if a ConnectionId is valid.
|
|||||||||||||||||||||||||||||
clearConnection | Clears a connection.
|
|||||||||||||||||||||||||||||
getConnectionId | Gets a ConnectionId.
|
|||||||||||||||||||||||||||||
getPublicKey | Gets the RSA password encryption key.
|
|||||||||||||||||||||||||||||
getSqlDataSet | Gets a DataSet from a SQL query and returns an XML string
version of the DataSet. The DataSet can be reconstructed in the client with:
DataSet ds = new DataSet( xml );
|
|||||||||||||||||||||||||||||
getVersion | Returns the LabVantage version, build, and patch numbers.
|
|||||||||||||||||||||||||||||
processAction | Processes a request to execute an Action.
|
|||||||||||||||||||||||||||||
translateTable | Returns a Property List with translated values.
|
Note that the operations above make generic calls to the LabVantage Java Public API (such as getSqlDataSet and processAction). They also use LabVantage-specific XML structures to send/receive data to/from the Web Service, i.e., XML is sent within XML. This can sometimes be inefficient, since LabVantage objects must be manually serialized to LabVantage XML structures, then deserialized in the client using the XML structure to create the objects. Note that the LabVantage propertylist and dataset XML does not use standard XML ddt or schema, and is therefore not recognized by other languages.
To provide more efficient execution, the additional methods below used Transport Beans for classes that handle entities such as for Data Sets, Property Lists, and SDI Data. These are Java Bean Wrappers for classes that are built from primitives and expose get and set properties. Each complex LabVantage API object is therefore wrapped by a primitive Java Bean and return the Java Bean objects. This means that the SOAP interface in the LabVantage Axis engine and on the .NET (or other language) client is responsible for serialization. LabVantage therefore needs not know anything about the object, so it can be used "as-is" on the client. This allows direct object interaction with SOAP languages such as .NET. For example, you can send a Property List object to the Web Service call to process an Action. With the old methods and XML structures, you would have to send a Property List XML string... which the 3rd party vendor does not know how to build. The more complex methods such as getSDIData, getSDCProperties and getDatabaseList let you use functionality available through the LabVantage Java Public API to query the database. You can therefore do things such as query SDCs for primary and detail tables from any external language, rather than having to know the exact SQL and data structure of LabVantage.
LabVantage Java Public API Method |
Corresponding LabVantage Web Service Method (in private package) |
translateTable | public PropertyListTransportBean translateTable( String connectionid, String languageid, PropertyListTransportBean propertyList ) throws SOAPException |
checkConnection | public boolean checkConnection( String connectionid ) throws SOAPException |
getDatabaseList | public String[] getDatabaseList() |
getSqlDataSet | public DataSetTransportBean getSqlDataSet(String connectionId, String sql, boolean returnClobs ) throws SOAPException |
getSDCProperties | public PropertyListTransportBean getSDCProperties(String connectionId, String sdcid) throws SOAPException |
getSDIData | public SDIDataTransportBean getSDIData(String connectionId, SDIRequestTransportBean sdireqbean ) throws SOAPException |
processAction | public PropertyListTransportBean processAction( String connectionid, String actionid, String actionversionid, PropertyListTransportBean propertyList ) throws SOAPException |
processActionBlock | public ActionBlockTransportBean processActionBlock( String connectionid, ActionBlockTransportBean block) throws SOAPException |
getSequence | public int getSequence( String connectionid, String sdcid, String sequenceid, int startsequencenumber, int incrementby ) throws SOAPException |
LabVantage Action Public Interface |
Corresponding LabVantage Web Service Method (in private package) |
processMessage | processMessage( String connectionid, BaseSECMessage message, String processingMode ) throws SOAPException |
getSDIAttachment | public AttachmentTransportBean getSDIAttachment( String connectionid, String sdcid, String keyid1, String keyid2, String keyid3, int attachmentNum, boolean zip ) throws SOAPException |
editSDIAttachment | There is no Action Public Interface in LabVantage, but
the method is:
public void editSDIAttachment( String connectionid, String sdcid, String keyid1, String keyid2, String keyid3, int attachmentNum, AttachmentTransportBean attachment ) throws SOAPException |
addSDIAttachment | public void addSDIAttachment( String connectionid, String sdcid, String keyid1, String keyid2, String keyid3, AttachmentTransportBean attachment ) throws SOAPException |
deleteSDIAttachment | public void deleteSDIAttachment( String connectionid, String sdcid, String keyid1, String keyid2, String keyid3, int attachmentNum ) throws SOAPException |
SapphireWS Examples |
The four examples described below use the SapphireWS Web Service to demonstrate various Web Service techniques. These examples assume that you know how to compile and run Java classes. Note that the declared package in each file is com.labvantage.training, so structure your environment accordingly.
Source File | Description |
RunWebService1.java | This example uses the Axis client in Java to run the pre-R5.2
processAction call that accepts a PropertyList XML and returns XML. The
class prompts for all information required to connect to the database as
shown in the console output below:
Enter Server: sskocypect400us |
RunWebService2.java | This is similar to RunWebService2 in that it uses the Axis client in Java to run some Actions. However, this class shows how to use the more complex objects to run an Action Block. The important thing to note is that this manually generates the types and has access to the stub classes; in other words, this works if you access to sapphire.jar. If you do not have access to sapphire.jar or do not know the types, you would have to use WSDL2Java (or another utility) to generate remote stubs from the WSDL. The prompts are similar to runWebService1.java. |
RunWebService3.java | This is another basic example of using Java client Web Services
to use one of the pre-R5.2 methods that accepts XML strings. Note that you
must change the endpoint to the correct WSDL address and enter you own database
connection details. The console output is shown below. Sent....connectionid = 'lab060040jbs512|(system)9979748314004' |
RunWebService4.java | This is a basic example of using the client Web Services
to call the latest (and more complex) methods to return a PropertyList object.
This class calls getSDCProperties. Note that you must change the endpoint
to the correct WSDL address and enter you own database connection details.
As is the case with RunWebService2, this assumes you can access sapphire.jar
(or generate stubs if you do not). The console outputs a PropertyList (which
is rather lengthy, a portion of which is shown here):
Object sdc details... ... AND SO ON UNTIL... </propertylist> |
SapphireBasicWS |
|
|
Enabling Ajax/JAX Web Services |
Before proceeding, you must make certain the Ajax/JAX Web Services are enabled. Enable them if necessary by setting the Web Services → Enable property in the Security Policy to "Yes". Save, then restart the Application Server and the LabVantage application.
Generating the WSDL for SapphireBasicWS |
Generate the WSDL file as follows:
1. | Open the SapphireWS WSDL by pointing the Web browser to this URL:
http://<hostname>:<port>/<webapp>/services/SapphireBasicWS?wsdl where <hostname>, <port>, and <webapp> indicate relevant values for the local machine. The WSDL should be rendered in the browser. |
2. | Save the WSDL in a directory of your choice. |
The JAX-WS implementation permits using SOAP to directly call the WS endpoints without any stubs.
SapphireBasicWS Web Service Operations |
These operations are available with SapphireBasicWS. These entry point methods accept primitive types and are WS-I compliant.
Operation | Description | |||||||||||||||||||||||||||||
checkConnection |
Determines if a ConnectionId is valid:
boolean checkConnection( String connectionid )
|
|||||||||||||||||||||||||||||
clearConnection |
Clears a connection.
void clearConnection( String connectionid )
|
|||||||||||||||||||||||||||||
getConnectionId |
Gets a ConnectionId.
String getConnectionId( String databaseid, String userid, String password )
|
|||||||||||||||||||||||||||||
getPublicKey |
Gets the RSA password encryption key.
String getPublicKey()
|
|||||||||||||||||||||||||||||
getSequence |
Gets the next sequence number of an SDC.
int getSequence( String connectionid, String sdcid, String sequenceid, int startsequencenumber, int incrementby )
|
|||||||||||||||||||||||||||||
getSqlDataSet |
Gets a DataSet from a SQL query and returns an XML string version of
the DataSet. The DataSet can be reconstructed in the client with DataSet
ds = new DataSet( xml );
String getSqlDataSet( String connectionid, String sql )
|
|||||||||||||||||||||||||||||
getVersion |
Returns the LabVantage version, build, and patch numbers.
String getVersion()
|
|||||||||||||||||||||||||||||
processAction |
Processes a request to execute an Action.
String processAction( String connectionid, String actionid, String actionversionid, String propertyListXML )
|
|||||||||||||||||||||||||||||
processMessage |
Processes a LabVantage Enterprise Connector message.
String processMessage( String connectionid, String id, String typeId, String message, String processingMode )
|
HTTPS |
|
|
For guidelines concerning use of Axis/Jax Web Services over HTTPS connections, see Guidelines for Using Web Services over HTTPS.