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(); } } }
No comments:
Post a Comment