on 06-24-2015 9:27 PM
Hello experts,
I am working on SAPWM 6.2 application. I have requirement to consume a web service to upload attachment for Notification on xECM. But to achieve this I need File path to get into my java code. I don't idea how can I can get it in java from Agentry. Also how could I connect my java code consuming web service to SAPWM application. Any suggestion will be very helpful.
Regards
Sudhir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sudhir,
Consider this as your development scenario....
1)Client------------------------->Server
| }Here server and client are on same machine
Repository(HDD)
2)Client------------------------->Server
| | }Here server and client are different machine
Repo.(HDD) Repo.(HDD)
Ideal setup would/should be like case 2) shown above...
So path that you might be expecting in java code wont be valid.Since you uploaded a file from your client(device) and on server side you are expecting file path which is not available there.
----------------------------------------------------------------------
So
In your java code access transaction value (for external data) using "transaction.<filedata property name>".
This will be a String in java (binary base 64 encoded string).
Then do what you wanted with it like decode it and upload it to another server.
Also i would like to know how you will upload a file from plain java using your web service to server.
Paste some java code that you are using so that we can help,
like you might be using
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
etc....
Regards,
AK
Hi,
If your code in java is able to upload a file "c:\\eye.jpg" to targeted server then your task is almost done.
just add following lines to your code
1) get file data using transaction property
String data = this._user.getString("transaction.<your filedata property name>");
2) Convert it to bytes array and write to file in server temp dir.
byte[] bytesData = data.getBytes();
FileOutputStream strm = new FileOutputStream("C:\\Temp");//----->server side directory and file
try {
strm.write(bytesData);
}
catch(Exception ex){
}
finally {
strm.close();
}
3) And in your code use same file to upload it.
File POAFilebyteArray = new File("C:\\Temp"); ------->>> File Path
reqEntity.addPart("file", new FileBody(POAFilebyteArray));
httppost.setEntity(reqEntity);
System.out.println("executing request " + httppost.getRequestLine());
HttpResponse response = httpclient.execute(httppost);
And also refer to Steps that Bill Froelich has suggested.
Regards,
AK
Sudhir,
What java path are you trying to get? The file will arrive at the server Java layer in a transaction property as a binary encoded string. It is up to you as to what you need to do with that. If needed you can write it out to a temporary directory prior to sending it up to xECM via the webservice.
Since your code is writing out the file, you will most likely end up with a File handle reference that will have methods to give you the path.
--Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill,
I have attached screenshot which contains File path of atttachment that I needed to have in Java code to upload that doc to xECM server.
// Supply File path //
File POAFilebyteArray = new File(" File path ") ;
So If possible can I get file path directly in this line of Java code.
Regards
Sudhir
Sudhir,
The path you indicate in the screen shot is the local path on the client device. The Agentry client will use that path to pickup the file from the device and embed it in the transaction.
That data will be sent to the server during the transmit process. As AK indicates, you can access that through your transaction properties in the Java code. What happens next is up to you based on the requirements of the web service you are trying to call.
I would anticipate the steps being something like this
--Bill
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.