Thursday, August 27, 2009

Invoking a process through webservices: Code

So I ran the installation and heres the basic code to invoke the process through its webservice endpoint.
Notice invoke_Async to invoke a long lived process asynchronously. I also had to make sure that i set the content type of the document that i was sending as a pdf. The classes are supplied when i create proxy classes from the webservice which is done through the Axis' WSDL2Java command. However, i learnt that Eclipse has a functionality that will automatically create the stubs for you based on a wsdl. Makes life alot easier.

 
public class ExpenseProcessInvokeWebService { public static void main(String[] args){ try{ //create a service locator ExpenseProcessServiceLocator locate = new ExpenseProcessServiceLocator(); //specify the service target URL and object type URL serviceURL = new URL("http://yyzdev3:8080/soap/services/ExpenseProcess?blob=dime"); //Use the binding stub with the locator ExpenseProcessSoapBindingStub expenseClientStub = new ExpenseProcessSoapBindingStub(serviceURL,locate); expenseClientStub.setUsername("administrator"); expenseClientStub.setPassword("password"); //Get the DIME Attachments - which is the PDF document to encrypt java.io.File file = new java.io.File("/home/bileni/Documents/Livecycle/ExpenseProject/Form/expense19-8-2009.pdf"); //Create a DataHandler object DataHandler buildFile = new DataHandler(new FileDataSource(file)); //Use the DataHandler object to create an AttachmentPart object AttachmentPart part = new AttachmentPart(buildFile); //part.setContentType("application/pdf"); part.setMimeHeader("Content-Type", "application/pdf"); System.out.println(part.getContentType()); //get the attachment ID String attachmentID = part.getContentId(); //Add the attachment to the encryption service stub expenseClientStub.addAttachment(part); //Inform ES where the attachment is stored by providing the attachment id BLOB inDoc = new BLOB(); inDoc.setAttachmentID(attachmentID); expenseClientStub.invoke_Async(1, null, inDoc); } catch(Exception e){ e.printStackTrace(); } } }

Tuesday, August 18, 2009

Invoking a process through webservices: Axis

I'm in the process of learning how to invoke a livecycle process through a java servlet using webservices. What I needed to do was to have Apache Axis installed to create Java proxy classes for the webservice endpoint of my process. So what I did was rather than install it on my local machine (and have to instal tomcat as well), I installed on the LC server and mounted the shared drive. This makes it much easier to develop and deploy apps.

So just a quick run trhu of the steps I had to take;
1) Download and untar the Axis download
2) copy it to the deploy folder (LCDIR/jboss/server/all/deploy)
3) Copy the xml parser jars from whatever xml parser distribution that you want to use (I used Xerces) into the lib folder of what you had just copied over
4) Create environment variables (unix);
export AXIS_HOME=/usr/axis
export AXIS_LIB=$AXIS_HOME/lib
export AXISCLASSPATH=$AXIS_LIB/axis.jar:$AXIS_LIB/commons-discovery.jar:
$AXIS_LIB/commons-logging.jar:$AXIS_LIB/jaxrpc.jar:$AXIS_LIB/saaj.jar:
$AXIS_LIB/log4j-1.2.8.jar:$AXIS_LIB/xml-apis.jar:$AXIS_LIB/xercesImpl.jar:
$AXIS_LIB$/wsdl4j-1.5.1.jar
5) Test axis at http://server:8080/axis

More detail at http://ws.apache.org/axis/java/install.html

Wednesday, August 5, 2009

Checking the signature with Javascript

To check if the signature has been signed from within the form itself, first get the field using
var digSig = event.target.getField("form1[0].#subform[0].Submit[0].Signature[0]");
Its important to use the fully qualified path to the signature.

Once thats done you can use this check the status
var status = digSig.signatureInfo().status;
The possible values you can get are

-1: not a signature field
0: signature is blank
1: unknown status
2: signature is invalid
3: signature is valid, identity of signer could not be verified
4: signature and identity of signer are both valid