Foren

Access to Liferay SOAP Web Services with credentials

thumbnail
Ivano Carrara, geändert vor 15 Jahren.

Access to Liferay SOAP Web Services with credentials

Expert Beiträge: 345 Beitrittsdatum: 03.07.05 Neueste Beiträge
Hi all!

After many try to access Liferay's SOAP Web Services from soapui and other tools, stil I'm not able to get success...

Using the endpoint "http://<numericuserid>:<password>@<host>:8080/tunnel-web/secure/axis/Portal_UserService" I get the error "This request requires HTTP authentication ().".

Note that also the "liferay-portal-client" portlet it's not able to run... If you download the portlet from the official repository of Liferay and deploy it on a Version 5.1.x portal you get many errors ....

Please, anyone is using the Liferay's SOAP Web Services?

No problem using a service that not require authentcation, for example getDefaultUser or Version.

Thank you very much in advance!

Ivano Carrara
thumbnail
Ivano Carrara, geändert vor 15 Jahren.

RE: Access to Liferay SOAP Web Services with credentials

Expert Beiträge: 345 Beitrittsdatum: 03.07.05 Neueste Beiträge
I resolved ... was my fault!

Using SOAP Web Services client tools I have to put the exact credentials in the right place ... My faul was that I add the credentials directly in the URL, for example: http://<userId>:<password>@localhost:8080/tunnel-web/........

Thank you and excuse me!

Ivano Carrara
thumbnail
Jonas Yuan, geändert vor 14 Jahren.

RE: Access to Liferay SOAP Web Services with credentials

Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Hi Ivano,

Great! Do you have examples to create an organization by SOAP?

Such as

OrganizationServiceSoap soap;

soap.addOrganization ....

Thanks

Jonas Yuan
--------
Liferay Books

Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
thumbnail
Jonas Yuan, geändert vor 14 Jahren.

RE: Access to Liferay SOAP Web Services with credentials

Liferay Master Beiträge: 993 Beitrittsdatum: 27.04.07 Neueste Beiträge
Fortunately, I got these functions working via SOAP, recently.

See (under construction)

http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Web+services+-+Manage+Users%2C+Organizations%2C+User+Groups%2C+and+Roles+via+SOAP

Thanks

Jonas Yuan
---
Liferay Books
Liferay Portal 5.2/5.3 Systems Development
Liferay Portal 4.4/5.0 Enterprise Intranets
thumbnail
Abhay Kumar, geändert vor 14 Jahren.

RE: Access to Liferay SOAP Web Services with credentials

New Member Beiträge: 21 Beitrittsdatum: 21.07.09 Neueste Beiträge
Hi,

I am using workflow portlet in which I need to use SOAP for fetching user info for the purpose of notification, but getting 401 unauthorized. I feel this error is somewhat similar to what you were getting, could you please share how you fixed it


thks
Paolo Bianchi, geändert vor 14 Jahren.

RE: Access to Liferay SOAP Web Services with credentials

New Member Beiträge: 9 Beitrittsdatum: 18.09.09 Neueste Beiträge
Hi,
i'm experiencing the same problem Auth error if I use a user different from test.
If i use user test and pws test everything works fine. But i think i misunderstand the authentication methods.

I only need to have access to some functionality such as get user name, get laout, add layout, but at the same time i want to use an authentication user that differs from "test". I think that the two authentication scopes differs, one is for the "tunnel" plugin and the other one should be the user into liferay environment. Am I wrong?

Thx,
Paolo
Paolo Bianchi, geändert vor 14 Jahren.

RE: Access to Liferay SOAP Web Services with credentials

New Member Beiträge: 9 Beitrittsdatum: 18.09.09 Neueste Beiträge
Hi all,
as I understood in my short experience to access a service using tunnel-web you have to authenticate using a valid user that has the right permission for the service.
So if I want to retrieve a journal article i can use a normal user that has access to the journal and try to retrieve the article. The only one problem i met in this case is that you can't list the journal.

Bye
thumbnail
Abhay Kumar, geändert vor 14 Jahren.

RE: Access to Liferay SOAP Web Services with credentials

New Member Beiträge: 21 Beitrittsdatum: 21.07.09 Neueste Beiträge
I am trying to fetch email address using soap service and I am getting following, if anyone has some idead ..


org.xml.sax.SAXException: Invalid element in com.liferay.client.portal.model.UserSoap - firstName
at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:
1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
at org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeserializer.java:154)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:
1048)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.liferay.client.portal.service.http.Portal_UserServiceSoapBindingStub.getUserById(Port
al_UserServiceSoapBindingStub.java:722)
at com.liferay.jbpm.handler.RemindActorActionHandler.execute(RemindActorActionHandler.java:5
6)
at org.jbpm.graph.def.Action.execute(Action.java:123)
at org.jbpm.graph.def.Action$$FastClassByCGLIB$$7876e90e.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161)
at org.jbpm.graph.def.Action$$EnhancerByCGLIB$$755fcc31.execute(<generated>)
at org.jbpm.scheduler.exe.Timer.execute(Timer.java:84)
at org.jbpm.scheduler.impl.SchedulerThread.executeTimers(SchedulerThread.java:118)
at org.jbpm.scheduler.impl.SchedulerThread.run(SchedulerThread.java:70)


Here are the relevant classes involved in calling the service. (Actually these all are from the workflow handler package).

/**
 * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.liferay.jbpm.handler;

import com.liferay.client.portal.service.http.GroupServiceSoap;
import com.liferay.client.portal.service.http.GroupServiceSoapServiceLocator;
import com.liferay.client.portal.service.http.RoleServiceSoap;
import com.liferay.client.portal.service.http.RoleServiceSoapServiceLocator;
import com.liferay.client.portal.service.http.UserServiceSoap;
import com.liferay.client.portal.service.http.UserServiceSoapServiceLocator;
import com.liferay.util.Encryptor;
import com.liferay.util.portlet.PortletProps;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * <a href="DefaultHandler.java.html"><b><i>View Source</i></b></a>
 *
 * @author Charles May
 *
 */
public class DefaultHandler {

	protected URL getURL(String serviceName) throws MalformedURLException {
		return getURL(serviceName, true);
	}

	protected URL getURL(String serviceName, boolean authenticated)
		throws MalformedURLException {

		String url = PortletProps.get("soap.url");

		if (authenticated) {
			String userId = PortletProps.get("soap.user.id");
			String password = Encryptor.digest(
				PortletProps.get("soap.password"));

			int pos = url.indexOf("://");

			String protocol = url.substring(0, pos + 3);
			String host = url.substring(pos + 3, url.length());

			url =
				protocol + userId + ":" + password + "@" + host +
					"/tunnel-web/secure/axis/" + serviceName;
		}
		else {
			url += "/tunnel-web/axis/" + serviceName;
		}

		return new URL(url);
	}

	protected GroupServiceSoap getGroupService() throws Exception {
		GroupServiceSoapServiceLocator locator =
			new GroupServiceSoapServiceLocator();

		GroupServiceSoap service = locator.getPortal_GroupService(
			getURL("Portal_GroupService"));

		return service;
	}

	protected RoleServiceSoap getRoleService() throws Exception {
		RoleServiceSoapServiceLocator locator =
			new RoleServiceSoapServiceLocator();

		RoleServiceSoap service = locator.getPortal_RoleService(
			getURL("Portal_RoleService"));

		return service;
	}

	protected UserServiceSoap getUserService() throws Exception {
		UserServiceSoapServiceLocator locator =
			new UserServiceSoapServiceLocator();

		UserServiceSoap service = locator.getPortal_UserService(
			getURL("Portal_UserService"));

		return service;
	}

	protected String swimlane;
	protected String msg;

}


/**
 * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.liferay.jbpm.handler;

import com.liferay.client.portal.model.UserSoap;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.GetterUtil;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.exe.SwimlaneInstance;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.jbpm.taskmgmt.exe.TaskMgmtInstance;

/**
 * <a href="RemindActorActionHandler.java.html"><b><i>View Source</i></b></a>
 *
 * @author Charles May
 *
 */
public class RemindActorActionHandler
	extends DefaultHandler implements ActionHandler {

	public void execute(ExecutionContext executionContext) throws Exception {
		TaskMgmtInstance taskMgmtInstance =
			executionContext.getTaskMgmtInstance();

		SwimlaneInstance swimlaneInstance =
			taskMgmtInstance.getSwimlaneInstance(swimlane);

		String userId = swimlaneInstance.getActorId();

		[quote]UserSoap user = getUserService().getUserById(
			GetterUtil.getLong(userId));[/quote]

		TaskInstance taskInstance = executionContext.getTaskInstance();

		if (_log.isInfoEnabled()) {
			_log.info(
				"Task is " + taskInstance.getName() + " waiting for " +
					user.getEmailAddress());
		}
	}

	private static Log _log =
		LogFactoryUtil.getLog(RemindActorActionHandler.class);

}
Dmitry Babain, geändert vor 14 Jahren.

RE: Access to Liferay SOAP Web Services with credentials

Regular Member Beiträge: 238 Beitrittsdatum: 23.11.08 Neueste Beiträge
Try this instead

user = UserLocalServiceUtil.getUserById(GetterUtil.getLong(userId));

It allows you to skip all this "true" service routine.

Resulting action class have to be inside jbpm artifact.
chandra sekhar, geändert vor 14 Jahren.

RE: Access to Liferay SOAP Web Services with credentials

Regular Member Beiträge: 149 Beitrittsdatum: 07.07.09 Neueste Beiträge
Hi,

Can you explain me indetail about how to invoke the liferay webservice from external world.

Thanks in advance

Regard,
chandra sekhar