Forums de discussion

Use of the Portlet_DDM_DDMStructureService service

Jorge Hortelano, modifié il y a 10 années.

Use of the Portlet_DDM_DDMStructureService service

New Member Publications: 14 Date d'inscription: 10/09/13 Publications récentes
I have develop some clients to use liferay's web services successfully. Now I am trying to implement a new one to add Dinamic Data List and Data Definitions automatically from an external application.

I connect to the service using:

DDMStructureServiceSoapServiceLocator locatorDDM = new DDMStructureServiceSoapServiceLocator();
setServiceSoap(locatorDDM.getPortlet_DDM_DDMStructureService(AccessUtils.getLiferayUrl(loginUser, password, getServiceName())));


Where "getLiferayUrl" and "getServiceName" gets information of the connection of the web service.

Then, I create the next method:


public DDMStructureSoap createDataType(String title, String xsd) {
		ServiceContext serviceContext = new ServiceContext();
		serviceContext.setScopeGroupId(GROUP_ID);
		serviceContext.setUserId(USER_ID);
		serviceContext.setCompanyId(COMPANY_ID);

		String[] nameMapLanguageIds = { "en_GB" };
		String[] nameMapValues = { "Test Title String" };
		String[] descriptionMapLanguageIds = { "en_GB" };
		String[] descriptionMapValues = { "Test Description String" };

		try {
			DDMStructureSoap structure = ((DDMStructureServiceSoap) getServiceSoap()).addStructure(
                                        GROUP_ID, // groupId
					DDMStructureConstants.DEFAULT_PARENT_STRUCTURE_ID, // classNameId
					title, // structureKey
					nameMapLanguageIds, // nameMapLanguageIds
					nameMapValues, // nameMapValues
					descriptionMapLanguageIds, // descriptionMapLanguageIds
					descriptionMapValues, // descriptionMapValues
					xsd,// xsd
					"xml",// storageType: xml or expando
					DDMStructureConstants.TYPE_DEFAULT,// type
					serviceContext // serviceContext
					);
			return structure;
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}


USER_ID, GROUP_ID, and COMPANY_ID now are statics values for testing, and are already existing values on database.
getServiceSoap() returns the stored element by setServiceSoap() used when connecting.
The parameter 'xsd' has the XML structure copied from database from an already existing data definition.

When executing this method, I have a generic error:

AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.rmi.RemoteException
 faultActor:
 faultNode:
 faultDetail:
        {http://xml.apache.org/axis/}hostname:dtbiit2

java.rmi.RemoteException
        at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
        at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
...


The error is not so explanatory by itself. But on the server log, I have:


11:45:52,259 ERROR [http-bio-8080-exec-7][DDMStructureServiceSoap:95] com.liferay.portal.security.auth.PrincipalException
com.liferay.portal.security.auth.PrincipalException
        at com.liferay.portlet.dynamicdatamapping.service.permission.DDMPermission.check(DDMPermission.java:32)
        at com.liferay.portlet.dynamicdatamapping.service.impl.DDMStructureServiceImpl.addStructure(DDMStructureServiceImpl.java:48)
        at sun.reflect.GeneratedMethodAccessor523.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:122)
...


This error, if I have understood correctly, means that user has not permissions to use this web service. It is a little weird because this user now has all permissions possible (administrator for the site, liferay, and all others).

On the other hand, I have also test other methods such as:


DDMStructureServiceSoap.updateStructure(...); //Using same XSD string that I want to use in the 'addStructure' method. 


and


DDMStructureServiceSoap.deleteStructure(...); 


These methods work perfectly fine with the same user: I can delete Data Definitions, I can update existing ones but I cannot create a new one. Always with same user and password.

(I am using Liferay 6.1.1)

I am not sure if the creating a new one needs some "special" permissions or not (I have created user, roles, articles without any problem and the methods are very similar). But I have not found any solutions to this behaviour in the documentation. I have not found neither any useful example on the web, then I have no idea where the error can be.

Could someone give a clue about the problem? I much appreciate.
Jorge Hortelano, modifié il y a 10 années.

Problem with some WebServices in Liferay

New Member Publications: 14 Date d'inscription: 10/09/13 Publications récentes
I am going to simplify the question:

I am creating an application that use Liferay 6.1.1 WebServices to exchange information with the portal.
I have successfully use web services for get user information, role, groups and others. But I have some issues with the webservice: "Portlet_DDM_DDMStructureService".
In Liferays logI can see this error:


09:18:39,898 ERROR [http-bio-8080-exec-7][DDMStructureServiceSoap:95] com.liferay.portal.security.auth.PrincipalException
com.liferay.portal.security.auth.PrincipalException
        at com.liferay.portlet.dynamicdatamapping.service.permission.DDMPermission.check(DDMPermission.java:32)
        at com.liferay.portlet.dynamicdatamapping.service.impl.DDMStructureServiceImpl.addStructure(DDMStructureServiceImpl.java:48)


Normally, this error is related to permission issues. But I can successfully use other web services in the same way that this one (same user, password, ...). Is there any known bug or configuration that is unknown to me? The user has all available Liferay's permissions.

Thanks in advance.
Jorge.
thumbnail
Ahmed Hasan, modifié il y a 10 années.

RE: Problem with some WebServices in Liferay

Expert Publications: 306 Date d'inscription: 13/04/07 Publications récentes
Hi Jorge,

Can you please get me the implementation of "AccessUtils". Are you passing emailAddress or userId for "userLogin". It has to be userId and the portal should now be configured to login through userId. Please confirm and let me know.

Yours truly,
Ahamed Hasan
Author, Liferay Portlet Cookbook
Jorge Hortelano, modifié il y a 10 années.

RE: Problem with some WebServices in Liferay

New Member Publications: 14 Date d'inscription: 10/09/13 Publications récentes
Hi Ahmed Hasan,

Access Utils is simply creating the URL for connecting to the webservice. In this case returns:
http://test%40liferay.com:test@localhost:8080/lportal-6.1.1/api/secure/axis/Portlet_DDM_DDMStructureService

As you can see, I am using the email "test@liferay.com" for my own tests, not the userId as you suggest. But, also I have used the email for all other webservices without any error. I have just checked out to be sure.

Thanks for your answer. I appreciate your efforts.
Jorge Hortelano, modifié il y a 10 années.

RE: Problem with some WebServices in Liferay

New Member Publications: 14 Date d'inscription: 10/09/13 Publications récentes
I have already test other web services such as: search, update, delete in DDMStructureServiceSoap, Only insert creates this error.
For DDL objects seems that everything works fine. Then I assume that is some kind of bug.
How can I report it?
thumbnail
Ahmed Hasan, modifié il y a 10 années.

RE: Problem with some WebServices in Liferay

Expert Publications: 306 Date d'inscription: 13/04/07 Publications récentes
Hi Jorge,

You can try once with the userId. If the bug still persists you can report it through http://issues.liferay.com.

Yours truly,
Ahamed Hasan
Author, Liferay Portlet Cookbook
Jorge Hortelano, modifié il y a 10 années.

RE: Problem with some WebServices in Liferay

New Member Publications: 14 Date d'inscription: 10/09/13 Publications récentes
Ok, I have repeated the test with the user id and not the email, and the web service returned the error (401) Not authorized.
Also the other test now fail with same error (as expected).

I will report the error. Thanks for the information.