how to do the remote access files
how to do the remote access files
https://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=74291284
2024-03-28T21:02:46Z
2024-03-28T21:02:46Z
how to do the remote access files
Ramalingaiah. D
https://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=74291283
2016-05-17T09:25:18Z
2016-05-17T09:25:18Z
Hi,<br /><br />http://localhost:8088/api/axis/Portlet_DL_DLAppService?wsdl<br /><br />i have added above URL ---> api in web service ,<br />but Remote files not working <br /><br /><br /> package com.ERPUploadFiles;<br /><br />import java.io.File;<br />import java.io.FileInputStream;<br />import java.io.IOException;<br />import java.net.MalformedURLException;<br />import java.net.URL;<br />import java.rmi.RemoteException;<br /><br />import javax.xml.rpc.ServiceException;<br /><br />import com.liferay.portal.service.ServiceContext;<br />import com.liferay.portlet.documentlibrary.service.http.DLAppServiceSoap;<br />import com.liferay.portlet.documentlibrary.service.http.DLAppServiceSoapServiceLocator;<br /><br /><br />public class UploadFiles {<br /> <br /> public static void uploadFile(File file) throws ServiceException, RemoteException, IOException{<br /> <br /> ServiceContext serviceContext=new ServiceContext();<br /> <br /> DLAppServiceSoapServiceLocator locator= new DLAppServiceSoapServiceLocator();<br /> <br /> DLAppServiceSoap service=locator.getPortlet_DL_DLAppService(getURL("Portlet_DL_DLAppService"));<br /> <br /> //System.out.println("url>>>"+sb.toString());<br /> service.addFileEntry(11505, 11586, file.getName(), "", file.getName(), file.getName(), "", getFileBytes(file), serviceContext);<br /> <br /> }<br /> <br /> private static URL getURL(String serviceName) throws MalformedURLException {<br /> //String Url = "";<br /> String url = "http://localhost:8088"; // ip address of liferay server ex. = http://45.76.28.19:8181<br /> String screenName = "ram";<br /> String password = "test";<br /> int pos = url.indexOf("localhost:/C:/Dev/new.txt.txt");<br /> String protocol = url.substring(0, pos + 3);<br /> String host = url.substring(pos + 3, url.length());<br /> StringBuilder sb = new StringBuilder();<br /> sb.append(protocol);<br /> sb.append(screenName);<br /> sb.append(":");<br /> sb.append(password);<br /> sb.append("@");<br /> sb.append(host);<br /> sb.append("/api/axis/");<br /> sb.append(serviceName);<br /> //System.out.println("url>>>"+sb.toString());<br /> return new URL(sb.toString());<br /> <br /> }<br /> <br /> private static byte[] getFileBytes(File file) throws IOException{<br /> FileInputStream fileInputStream=null;<br /> byte[] bFile = new byte[(int) file.length()];<br /> //convert file into array of bytes<br /> fileInputStream = new FileInputStream(file);<br /> fileInputStream.read(bFile);<br /> fileInputStream.close(); <br /> return bFile;<br /> }<br /> public static void main(String[] args) throws ServiceException, Exception {<br /> File file = new File("C:\\Dev\\new.txt.txt");<br /> LiferayUtil.uploadFile(file);<br /> System.out.println("url>>>"+file.toString());<br /> }<br /> <br /> <br /> }<br /><br /><br />but Remote files not working <br />please suggest me,<br /><br /><br />Regards<br