Content

Introduction

SapphireWS

Enabling Ajax/JAX Web Services

Generating the WSDL and Source Files for SapphireWS

SapphireWS Web Service Operations

SapphireWS Examples

 

SapphireBasicWS

Enabling Ajax/JAX Web Services

Generating the WSDL for SapphireBasicWS

SapphireBasicWS Web Service Operations

HTTPS

 

Introduction

Top../images/arwup.gif (846 bytes)

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

Top ../images/arwup.gif (846 bytes)

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:
axis.jar jaxrpc.jar
commons-logging.jar wsdl4j.jar
commons-discovery.jar junit.jar
commons-collections.jar sapphire.jar
commons.beanutils.jar   
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.
Input Message checkConnectionRequest
Input Parameter connectionid
ConnectionId (same information that is returned from method sapphire.accessor.ConnectionProcessor.getConnectionId()).
Output MessagecheckConnectionResponse
Output Parameter checkConnectionReturn
Returns true if the ConnectionId is valid (othewise returns false).
clearConnection Clears a connection.
Input Message clearConnectionRequest
Input Parameter ConnectionId
ConnectionId to clear.
Output MessageclearConnectionResponse
Output Parameter None.
getConnectionId Gets a ConnectionId.
Input Message getConnectionIdRequest
Input Parameters
OrderParameterDescription
1databaseidIdentifier of the database to which you are connected.
2useridIdentifier of the connected User.
3passwordUser's password.
Output MessagegetConnectionIdResponse
Output Parameter getConnectionIdReturn

Returns the ConnectionId.

getPublicKey Gets the RSA password encryption key.
Input Message getPublicKeyRequest
Input Parameter None.
Output MessagegetPublicKeyResponse
Output Parameter getPublicKeyReturn

RSA encryption key. This is used with the RSA algorithm to encrypt passwords (see Password Encryption).

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 );

Input Message getSqlDataSetRequest
Input Parameters
OrderParameterDescription
1connectionidConnectionId. This is the same information that is returned from method sapphire.accessor.ConnectionProcessor.getConnectionId().
2sql SQL required to populate the DataSet.
Output MessagegetSqlDataSetResponse
Output Parameter getSqlDataSetReturn

DataSet returned as an XML string. The DataSet can be reconstructed using:

DataSet ds = new DataSet( xml );

getVersion Returns the LabVantage version, build, and patch numbers.
Input Message getVersionRequest
Input Parameter None.
Output MessagegetVersionResponse
Output Parameter getVersionReturn

LabVantage version, build, and patch numbers. Example:

V4.7 (Build 0209.001.01 Patch 00)

processAction Processes a request to execute an Action.
Input Message processActionRequest
Input Parameters
OrderParameterDescription
1connectionidConnectionId. This is the same information that is returned from method sapphire.accessor.ConnectionProcessor.getConnectionId().
2actionidIdentifier of the Action to be processed.
3actionversionidVersion number of the Action.
4propertyListXML XML string generated by method sapphire.xml.PropertyList.toXML().

Use this method to generate the string, then pass the string into this property.

Output MessageprocessActionResponse
Output Parameter processActionReturn

Standard Action "(return)" property indicating Action success or failure. This is set into the Property List and available after the Action completes.

ValueDescription
1The Action successfully executed.
2The Action failed to execute.
translateTable Returns a Property List with translated values.
Input Message translateTableRequest
Input Parameters
OrderParameterDescription
1connectionidConnectionId. This is the same information that is returned from method sapphire.accessor.ConnectionProcessor.getConnectionId().
2languageidIdentifier of the Language SDI.
3propertyListXML XML string generated by method sapphire.xml.PropertyList.toXML().

Populate the Property Llist with values requiring translation, and the property values will be set to the translated values in the returned property list. Example:

sapphire.xml.PropertyList pl = new sapphire.xml.PropertyList();

pl.setProperty( "hello", "" );

pl.setProperty( "goodbye", "" );

String propertyListXML = pl.toXML();

Output MessagetranslateTableResponse
Output Parameter translateTableReturn

Property List with translated values. Example:

sapphire.xml.PropertyList pl = new sapphire.xml.PropertyList( returnedXML );

String translatedHello = pl.getProperty( "hello" );

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
Enter Port: 8080
Enter Web App: sapphire
RunWebService started...
Web service URL = http://sskocypect400us:8080/sapphire/services/SapphireWS?wsdl
Enter Database: lab060040jbs512
Enter Username: lab060040jbs512
Enter Password: lab060040jbs512
Sent....connectionid = 'lab060040jbs512|(system)1669603006983'
Enter Sample Description: Web Services Test Sample 001
Sent....action
New Sample: S-120329-00001

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'
ret = <propertylist>
<property id="sampledesc" type="simple"><![CDATA[Hello From WS]]></property>
<property id="copies" type="simple"><![CDATA[1]]></property>
<property id="applylock" type="simple"><![CDATA[]]></property>
<property id="(return)" type="simple"><![CDATA[1]]></property>
<property id="sdcid" type="simple"><![CDATA[Sample]]></property>
<property id="newkeyid1" type="simple"><![CDATA[S-120329-00003]]></property>
</propertylist>
Sent....action

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...
<propertylist>
<property id="keygenerationrule" type="simple"><![CDATA[A;T^2^S-^;D^7^yymmdd-^today^;Q^5^00000^2^1^;]]></property>
<property id="keyidusablesize" type="simple"><![CDATA[20]]></property>
<property id="notesflag" type="simple"><![CDATA[Y]]></property>
<property id="reverselinks" type="collection">
<collection>
<propertylist id="BasedOnSampleId;Sample">
<property id="loadflag" type="simple"><![CDATA[N]]></property>

... AND SO ON UNTIL...

</propertylist>

 

SapphireBasicWS

Top../images/arwup.gif (846 bytes)

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 )

Input Message checkConnectionRequest
Input Parameter connectionid
ConnectionId (same information that is returned from method sapphire.accessor.ConnectionProcessor.getConnectionId()).
Output MessagecheckConnectionResponse
Output Parameter checkConnectionReturn
Returns true if the ConnectionId is valid (othewise returns false).
clearConnection Clears a connection.

void clearConnection( String connectionid )

Input Message clearConnectionRequest
Input Parameter ConnectionId
ConnectionId to clear.
Output MessageclearConnectionResponse
Output Parameter None.
getConnectionId Gets a ConnectionId.

String getConnectionId( String databaseid, String userid, String password )

Input Message getConnectionIdRequest
Input Parameters
OrderParameterDescription
1databaseidIdentifier of the database to which the User is connected.
2useridIdentifier of the connected User.
3passwordUser's password.
Output MessagegetConnectionIdResponse
Output Parameter getConnectionIdReturn

Returns the ConnectionId.

getPublicKey Gets the RSA password encryption key.

String getPublicKey()

Input Message getPublicKeyRequest
Input Parameter None.
Output MessagegetPublicKeyResponse
Output Parameter getPublicKeyReturn

RSA encryption key. This is used with the RSA algorithm to encrypt passwords (see Password Encryption).

getSequence Gets the next sequence number of an SDC.

int getSequence( String connectionid, String sdcid, String sequenceid, int startsequencenumber, int incrementby )

Input Message getSequenceRequest
Input Parameters
OrderParameterDescription
1connectionidConnectionId. This is the same information that is returned from method sapphire.accessor.ConnectionProcessor.getConnectionId().
2sdcidIdentifier of the SDC.
3sequenceidIdentifier of the sequence.
4startsequencenumber Integer indicating the starting number of the sequence. This is an int data type.
5incrementbyInteger by which the sequence is incremented. This is an int data type.
Output MessagegetSequenceResponse
Output Parameter getSequenceReturn

Returns sequence parameters.

 

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 )

Input Message getSqlDataSetRequest
Input Parameters
OrderParameterDescription
1connectionidConnectionId. This is the same information that is returned from method sapphire.accessor.ConnectionProcessor.getConnectionId().
2sql SQL required to populate the DataSet.
Output MessagegetSqlDataSetResponse
Output Parameter getSqlDataSetReturn

DataSet returned as an XML string. The DataSet can be reconstructed using:

DataSet ds = new DataSet( xml );

getVersion Returns the LabVantage version, build, and patch numbers.

String getVersion()

Input Message getVersionRequest
Input Parameter None.
Output MessagegetVersionResponse
Output Parameter getVersionReturn

LabVantage version, build, and patch numbers.

processAction Processes a request to execute an Action.

String processAction( String connectionid, String actionid, String actionversionid, String propertyListXML )

Input Message processActionRequest
Input Parameters
OrderParameterDescription
1connectionidConnectionId. This is the same information that is returned from method sapphire.accessor.ConnectionProcessor.getConnectionId().
2actionidIdentifier of the Action to be processed.
3actionversionidVersion number of the Action.
4propertyListXML XML string generated by method sapphire.xml.PropertyList.toXML().

Use this method to generate the string, then pass the string into this property.

Output MessageprocessActionResponse
Output Parameter processActionReturn

Standard Action "(return)" property indicating Action success or failure. This is set into the Property List and available after the Action completes.

ValueDescription
1The Action successfully executed.
2The Action failed to execute.
processMessage Processes a LabVantage Enterprise Connector message.

String processMessage( String connectionid, String id, String typeId, String message, String processingMode )

Input Message processMessageRequest
Input Parameters
OrderParameterDescription
1connectionidConnectionId. This is the same information that is returned from method sapphire.accessor.ConnectionProcessor.getConnectionId().
2idIdentifer of the message.
3typeIdIdentifier of the message type.
4messageContent of the message.
5processingModeSpecify A for asynchonous, S for synchronous, or M for manual.
Output MessageprocessMessageResponse
Output Parameter processMessageReturn

Returns message parameters.

 

HTTPS

Top../images/arwup.gif (846 bytes)

For guidelines concerning use of Axis/Jax Web Services over HTTPS connections, see Guidelines for Using Web Services over HTTPS