Fórum
Json Webservices : Error while invoking URL
Ramalingaiah Dudidmetle, modificado 8 Anos atrás.
Json Webservices : Error while invoking URL
Expert Postagens: 486 Data de Entrada: 16/08/14 Postagens Recentes
Hi
I get the below error when i try to invoke JSON webservice.
http://localhost:8080/api/jsonws?signature=%2Fwebsite%2Fadd-website-5-className-classPK-url-typeId-primary#serviceResults.
com.liferay.portal.security.auth.PrincipalException: Please sign in to invoke this method.
Any help is greatly appreciated.
Regards,
Ram
I get the below error when i try to invoke JSON webservice.
http://localhost:8080/api/jsonws?signature=%2Fwebsite%2Fadd-website-5-className-classPK-url-typeId-primary#serviceResults.
com.liferay.portal.security.auth.PrincipalException: Please sign in to invoke this method.
Any help is greatly appreciated.
Regards,
Ram
Anil T, modificado 8 Anos atrás.
RE: Json Webservices : Error while invoking URL
Expert Postagens: 313 Data de Entrada: 14/01/12 Postagens Recentes
Hi,
It requires the admin authentication. Please log in with administrator and try access same service. I hope you will get it.
It requires the admin authentication. Please log in with administrator and try access same service. I hope you will get it.
Harish Kumar, modificado 8 Anos atrás.
RE: Json Webservices : Error while invoking URL
Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
Its a post request. you need to pass authentication information while making call to this service.
please check the documentation
please check the documentation
Ramalingaiah Dudidmetle, modificado 8 Anos atrás.
RE: Json Webservices : Error while invoking URL
Expert Postagens: 486 Data de Entrada: 16/08/14 Postagens Recentes
Hi Harish Kumar,
"Could not execute JDBC batch update; SQL [insert into Country (name, a2, a3, number_, idd_, zipRequired, active_, countryId) values (?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update"
thanks you so-mach replayed ,
Regards ,
Ram,
"Could not execute JDBC batch update; SQL [insert into Country (name, a2, a3, number_, idd_, zipRequired, active_, countryId) values (?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update"
thanks you so-mach replayed ,
Regards ,
Ram,
Harish Kumar, modificado 8 Anos atrás.
RE: Json Webservices : Error while invoking URL
Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
Hi
ConstraintViolationException is due to parameter values you are passing. please double check the parameters
ConstraintViolationException is due to parameter values you are passing. please double check the parameters
Ramalingaiah Dudidmetle, modificado 8 Anos atrás.
RE: Json Webservices : Error while invoking URL
Expert Postagens: 486 Data de Entrada: 16/08/14 Postagens Recentes
Hi Harish Kumar,
{
"a2": "IN",
"a3": "IND",
"active": true,
"countryId": 108,
"idd": "091",
"name": "india",
"nameCurrentValue": "India",
"number": "356",
"zipRequired": true
}
thanks you so-mach reply-ed,
ram
{
"a2": "IN",
"a3": "IND",
"active": true,
"countryId": 108,
"idd": "091",
"name": "india",
"nameCurrentValue": "India",
"number": "356",
"zipRequired": true
}
thanks you so-mach reply-ed,
ram
Harish Kumar, modificado 8 Anos atrás.
RE: Json Webservices : Error while invoking URL
Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
A record with 108 as countryid is already there. Are you trying to update this record.
Ramalingaiah Dudidmetle, modificado 8 Anos atrás.
RE: Json Webservices : Error while invoking URL
Expert Postagens: 486 Data de Entrada: 16/08/14 Postagens Recentes
Hi Harish Kumar,
Yes,
now
just in DMS folder project inside save the files in ERP appalications
please give me suggest.
Regards
Ram
Yes,
now
just in DMS folder project inside save the files in ERP appalications
please give me suggest.
Regards
Ram
Ramalingaiah Dudidmetle, modificado 8 Anos atrás.
RE: Json Webservices : Error while invoking URL
Expert Postagens: 486 Data de Entrada: 16/08/14 Postagens Recentes
Hi Harish Kumar,
package com.liferay.test1;
import java.net.URL;
import com.liferay.portal.model.CompanySoap;
import com.liferay.portal.model.UserGroupSoap;
import com.liferay.portal.service.http.CompanyServiceSoap;
import com.liferay.portal.service.http.CompanyServiceSoapServiceLocator;
import com.liferay.portal.service.http.UserGroupServiceSoap;
import com.liferay.portal.service.http.UserGroupServiceSoapServiceLocator;
import com.liferay.portal.service.http.UserServiceSoap;
import com.liferay.portal.service.http.UserServiceSoapServiceLocator;
public class LiferaySoapClient {
public static void main(String[] args) {
try {
String remoteUser = "test@liferay.com";
String password = "test";
String virtualHost = "localhost";
String groupName = "MyUserGroup";
String serviceCompanyName = "Portal_CompanyService";
String serviceUserName = "Portal_UserService";
String serviceUserGroupName = "Portal_UserGroupService";
long userId = 0;
// Locate the Company
CompanyServiceSoapServiceLocator locatorCompany =
new CompanyServiceSoapServiceLocator();
CompanyServiceSoap soapCompany =
locatorCompany.getPortal_CompanyService(
_getURL(remoteUser, password, serviceCompanyName,
true));
CompanySoap companySoap =
soapCompany.getCompanyByVirtualHost(virtualHost);
// Locate the User service
UserServiceSoapServiceLocator locatorUser =
new UserServiceSoapServiceLocator();
UserServiceSoap userSoap = locatorUser.getPortal_UserService(
_getURL(remoteUser, password, serviceUserName, true));
// Get the ID of the remote user
userId = userSoap.getUserIdByScreenName(
companySoap.getCompanyId(), remoteUser);
System.out.println("userId for user named " + remoteUser +
" is " + userId);
// Locate the UserGroup service
UserGroupServiceSoapServiceLocator locator =
new UserGroupServiceSoapServiceLocator();
UserGroupServiceSoap usergroupsoap =
locator.getPortal_UserGroupService(
_getURL(remoteUser, password, serviceUserGroupName,
true));
// Get the user's user groups
UserGroupSoap[] usergroups = usergroupsoap.getUserUserGroups(
userId);
System.out.println("User groups for userId " + userId + " ...");
for (int i = 0; i < usergroups.length; i++) {
System.out.println("\t" + usergroups.getName());
}
// Adds the user group if it does not already exist
String groupDesc = "My new user group";
UserGroupSoap newUserGroup = null;
boolean userGroupAlreadyExists = false;
try {
newUserGroup = usergroupsoap.getUserGroup(groupName);
if (newUserGroup != null) {
System.out.println("User with userId " + userId +
" is already a member of UserGroup " +
newUserGroup.getName());
userGroupAlreadyExists = true;
}
} catch (Exception e) {
// Print cause, but continue
System.out.println(e.getLocalizedMessage());
}
if (!userGroupAlreadyExists) {
newUserGroup = usergroupsoap.addUserGroup(
groupName, groupDesc);
System.out.println("Added user group named " + groupName);
long users[] = {userId};
userSoap.addUserGroupUsers(newUserGroup.getUserGroupId(),
users);
}
// Get the user's user groups
usergroups = usergroupsoap.getUserUserGroups(userId);
System.out.println("User groups for userId " + userId + " ...");
for (int i = 0; i < usergroups.length; i++) {
System.out.println("\t" + usergroups.getName());
}
}
catch (Exception e) {
e.getLocalizedMessage();
}
}
private static URL _getURL(String remoteUser, String password,
String serviceName, boolean authenticate)
throws Exception {
// Unauthenticated url
String url = "http://localhost:8080/api/axis/" + serviceName;
// Authenticated url
if (authenticate) {
url = "http://" + remoteUser + ":" + password
+ "@localhost:8080/api/axis/"
+ serviceName;
}
return new URL(url);
}
}
please help me ,
All setup working then
i create web project and added services after package com.liferay.test1;
this is a class LiferaySoapClient, inside code past
i want to output uploadfiles go for DMS project inside save
Regards
Ram
package com.liferay.test1;
import java.net.URL;
import com.liferay.portal.model.CompanySoap;
import com.liferay.portal.model.UserGroupSoap;
import com.liferay.portal.service.http.CompanyServiceSoap;
import com.liferay.portal.service.http.CompanyServiceSoapServiceLocator;
import com.liferay.portal.service.http.UserGroupServiceSoap;
import com.liferay.portal.service.http.UserGroupServiceSoapServiceLocator;
import com.liferay.portal.service.http.UserServiceSoap;
import com.liferay.portal.service.http.UserServiceSoapServiceLocator;
public class LiferaySoapClient {
public static void main(String[] args) {
try {
String remoteUser = "test@liferay.com";
String password = "test";
String virtualHost = "localhost";
String groupName = "MyUserGroup";
String serviceCompanyName = "Portal_CompanyService";
String serviceUserName = "Portal_UserService";
String serviceUserGroupName = "Portal_UserGroupService";
long userId = 0;
// Locate the Company
CompanyServiceSoapServiceLocator locatorCompany =
new CompanyServiceSoapServiceLocator();
CompanyServiceSoap soapCompany =
locatorCompany.getPortal_CompanyService(
_getURL(remoteUser, password, serviceCompanyName,
true));
CompanySoap companySoap =
soapCompany.getCompanyByVirtualHost(virtualHost);
// Locate the User service
UserServiceSoapServiceLocator locatorUser =
new UserServiceSoapServiceLocator();
UserServiceSoap userSoap = locatorUser.getPortal_UserService(
_getURL(remoteUser, password, serviceUserName, true));
// Get the ID of the remote user
userId = userSoap.getUserIdByScreenName(
companySoap.getCompanyId(), remoteUser);
System.out.println("userId for user named " + remoteUser +
" is " + userId);
// Locate the UserGroup service
UserGroupServiceSoapServiceLocator locator =
new UserGroupServiceSoapServiceLocator();
UserGroupServiceSoap usergroupsoap =
locator.getPortal_UserGroupService(
_getURL(remoteUser, password, serviceUserGroupName,
true));
// Get the user's user groups
UserGroupSoap[] usergroups = usergroupsoap.getUserUserGroups(
userId);
System.out.println("User groups for userId " + userId + " ...");
for (int i = 0; i < usergroups.length; i++) {
System.out.println("\t" + usergroups.getName());
}
// Adds the user group if it does not already exist
String groupDesc = "My new user group";
UserGroupSoap newUserGroup = null;
boolean userGroupAlreadyExists = false;
try {
newUserGroup = usergroupsoap.getUserGroup(groupName);
if (newUserGroup != null) {
System.out.println("User with userId " + userId +
" is already a member of UserGroup " +
newUserGroup.getName());
userGroupAlreadyExists = true;
}
} catch (Exception e) {
// Print cause, but continue
System.out.println(e.getLocalizedMessage());
}
if (!userGroupAlreadyExists) {
newUserGroup = usergroupsoap.addUserGroup(
groupName, groupDesc);
System.out.println("Added user group named " + groupName);
long users[] = {userId};
userSoap.addUserGroupUsers(newUserGroup.getUserGroupId(),
users);
}
// Get the user's user groups
usergroups = usergroupsoap.getUserUserGroups(userId);
System.out.println("User groups for userId " + userId + " ...");
for (int i = 0; i < usergroups.length; i++) {
System.out.println("\t" + usergroups.getName());
}
}
catch (Exception e) {
e.getLocalizedMessage();
}
}
private static URL _getURL(String remoteUser, String password,
String serviceName, boolean authenticate)
throws Exception {
// Unauthenticated url
String url = "http://localhost:8080/api/axis/" + serviceName;
// Authenticated url
if (authenticate) {
url = "http://" + remoteUser + ":" + password
+ "@localhost:8080/api/axis/"
+ serviceName;
}
return new URL(url);
}
}
please help me ,
All setup working then
i create web project and added services after package com.liferay.test1;
this is a class LiferaySoapClient, inside code past
i want to output uploadfiles go for DMS project inside save
Regards
Ram