I have implement one service like this,
first, declare one service with the input param:
<service name="ebsEntityUpload" engine="java" validate="true" auth="false" export="true"
location="com.e2ee.ofbiz.iebs.service.EBSEntityUpload" invoke="processUpload" use-transaction="false">
<description>EBS upload Data</description>
<attribute name="uploadedFile" type="java.nio.ByteBuffer" mode="IN" optional="false"/> <attribute name="messages" type="List" mode="OUT" optional="false"/>
</service>
in your java code,
public static Map<String, Object> processUpload(DispatchContext dctx, Map<String, ? extends Object> context) throws GenericEntityException {
try {
GenericValue userLogin = (GenericValue) context.get("userLogin");
ByteBuffer fileBytes = (ByteBuffer) context.get("uploadedFile"); Locale locale = (Locale) context.get("locale");
String fileName= System.currentTimeMillis()+".zip";
File fZip = new File(fileName);
FileOutputStream fo = new FileOutputStream(fZip.getAbsolutePath(), true);
fo.write(fileBytes.array()); fo.close();
I calling it use xmlrpc,
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL(url));
config.setBasicUserName(user);
config.setBasicPassword(passwd);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
File zipFile = new File(fileName);
byte[] content = new byte[(int)zipFile.length()];
FileInputStream fis = new FileInputStream(zipFile);
fis.read(content);
Object[] params = new Object[]{content,user,passwd};
Map<String, Object> result = (Map<String, Object>) client.execute("ebsEntityUpload", params);
Trenton Perceval wrote
Hi.
I have some use case to implement in OFBiz.
The situation is that on some Liferay portal I have a form that collects some data and executes remote OFBiz webservice to send it. Now I have to add a possibility to upload a file and send it through this webservice to OFBiz. Could you give me any hints how to start? For now, I don't know how to transfer files using OFBiz services.
Trenton Perceval wrote
Hi.
I have some use case to implement in OFBiz.
The situation is that on some Liferay portal I have a form that collects some data and executes remote OFBiz webservice to send it. Now I have to add a possibility to upload a file and send it through this webservice to OFBiz. Could you give me any hints how to start? For now, I don't know how to transfer files using OFBiz services.