Hi
first of all thanks for your post,
I was try your sample 1) and after adapting is working fine. But I want to invoke a service (DLFileEntry or DLApp) and in both cases i get the same error:
1java.lang.RuntimeException: No JSON web service action associated with path /dlapp/add-file-entry and method POST for /
the last code I test (for DLApp):
.
1......
2
3 String sTRgroupId = groupId+"";
4 String sTRfolderId = folderId+"";
5 String sTRfileEntryTypeId = fileEntryTypeId+"";
6 String sTRfieldsMap = JsonWriter.objectToJson(fieldsMap);
7 String sTRfile = JsonWriter.objectToJson(file);;
8 String sTRis = JsonWriter.objectToJson(is);;
9 String sTRsize =size+"";
10 String sTRscopeGroupId = scopeGroupId+"";
11 addFileEntry(sTRgroupId, sTRfolderId , title, description, sTRfileEntryTypeId , sTRfieldsMap, sTRfile, sTRis , sTRsize, sTRscopeGroupId );
12
13 public static void addFileEntry(String groupId, String folderId, String title, String description, String fileEntryTypeId, String fieldsMap, String file, String is, String size, String scopeGroupId) throws Exception {
14
15
16 HttpHost targetHost = new HttpHost("localhost",8080,"http");
17 DefaultHttpClient httpclient = new DefaultHttpClient();
18 httpclient.getCredentialsProvider().setCredentials(
19 new AuthScope(targetHost.getHostName(), targetHost.getPort()),
20 new UsernamePasswordCredentials("test@liferay.com", “****"));
21
22 // Create AuthCache instance
23 AuthCache authCache = new BasicAuthCache();
24 // Generate BASIC scheme object and add it to the local
25 // auth cache
26 BasicScheme basicAuth = new BasicScheme();
27 authCache.put(targetHost, basicAuth);
28
29 // Add AuthCache to the execution context
30 BasicHttpContext ctx = new BasicHttpContext();
31 ctx.setAttribute(ClientContext.AUTH_CACHE, authCache);
32
33 // HttpPost post = new HttpPost("/api/secure/jsonws/dlfileentry/add-file-entry");
34 HttpPost post = new HttpPost("/api/secure/jsonws/dlapp/add-file-entry");
35
36 List<NameValuePair> params = new ArrayList<NameValuePair>();
37// params.add(new BasicNameValuePair("serviceClassName", "com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil"));
38 params.add(new BasicNameValuePair("serviceClassName", "com.liferay.portlet.documentlibrary.service.DLAppServiceUtil"));
39 params.add(new BasicNameValuePair("serviceMethodName", "addFileEntry"));
40// dlapp params.add(new BasicNameValuePair("serviceParameters", "[groupId,repositoryId,folderId,sourceFileName,mimeType,title,description,changeLog,is,size,serviceContext]"));
41// dlapp params.add(new BasicNameValuePair("serviceParameterTypes", "[long,long,long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.io.InputStream,long,com.liferay.portal.service.ServiceContext]"));
42// params.add(new BasicNameValuePair("serviceParameters", "[groupId,repositoryId,folderId,sourceFileName,mimeType,title,description,changeLog,fileEntryTypeId,fieldsMap,file,is,size,serviceContext]"));
43// params.add(new BasicNameValuePair("serviceParameterTypes", "[long,long,long,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,long,java.util.Map,java.io.File,java.io.InputStream,long,com.liferay.portal.service.ServiceContext]"));
44
45 params.add(new BasicNameValuePair("groupId", groupId));
46 params.add(new BasicNameValuePair("repositoryId", "0"));
47 params.add(new BasicNameValuePair("folderId", folderId));
48 params.add(new BasicNameValuePair("title",title));
49 params.add(new BasicNameValuePair("description", description));
50 params.add(new BasicNameValuePair("changeLog", ""));
51// params.add(new BasicNameValuePair("fileEntryTypeId", fileEntryTypeId));
52// params.add(new BasicNameValuePair("fieldsMap", fieldsMap));
53// params.add(new BasicNameValuePair("file", file));
54 params.add(new BasicNameValuePair("is", is));
55 params.add(new BasicNameValuePair("size", size));
56 params.add(new BasicNameValuePair("serviceContext", "{}"));
57// params.add(new BasicNameValuePair("serviceContext.scopeGroupId", scopeGroupId));
58 UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "UTF-8");
59 post.setEntity(entity);
60 HttpResponse resp = httpclient.execute(targetHost, post, ctx);
61 System.out.println(resp.getStatusLine());
62 resp.getEntity().writeTo(System.out);
63 httpclient.getConnectionManager().shutdown();
64
65 }
Please sign in to flag this as inappropriate.