Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
Hir O
(401)Unauthorized while accessing web service Liferay 6
29 de marzo de 2012 20:58
Respuesta

Hir O

Ranking: Junior Member

Mensajes: 30

Fecha de incorporación: 14 de marzo de 2012

Mensajes recientes

Hi All,

I am trying to access web services in Liferay 6. I am using the following code.

java.net.URL url = new java.net.URL("http://test%40liferay.com:ldap@localhost:8080/tunnel-web/secure/axis/Portal_PermissionService");
cachedEndpoint = url;


I am getting (401) Unauthorized error and I am unable to access the services.

I am using Axis 1, and have generated stubs using SOAP UI.

I have implemented custom authorization, and that class actually gets called, I replaced %40 in the email address with @ (as I am have replaced @ symbol with %40 in the URL above) string in my custom authentication class and not that function returns success(i.e. 1) but still web service is unable to access the resources

I have in parallel tried the following as well

java.net.URL url1 = new java.net.URL("http://test%40liferay.com:ldap@localhost:8080/tunnel-web/secure/axis/Portal_PermissionService");
PermissionServiceSoap permissionService = service.getPortal_PermissionService(url1);
((Portal_PermissionServiceSoapBindingStub) permissionService).setUsername("test%40liferay.com");
((Portal_PermissionServiceSoapBindingStub)permissionService).setPassword("ldap");



Please help me solve this issue.
Hitoshi Ozawa
RE: (401)Unauthorized while accessing web service Liferay 6
29 de marzo de 2012 21:12
Respuesta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensajes: 7990

Fecha de incorporación: 23 de marzo de 2010

Mensajes recientes

Please check the following page. The sample is written for 6.0.5, but the concept is still the same.

http://www.liferay.com/community/wiki/-/wiki/Main/Web+Service+samples
Hir O
RE: (401)Unauthorized while accessing web service Liferay 6
29 de marzo de 2012 22:05
Respuesta

Hir O

Ranking: Junior Member

Mensajes: 30

Fecha de incorporación: 14 de marzo de 2012

Mensajes recientes

Hi Hitoshi,

Thanks for replying. I am not finding any of the files in my package from your link.

Please look at my following approach at calling axis ws from axis ws client.

I have my code generated from SOAP UI and have written a main function in PermissionServiceSoapBindingStub.java to test the WS currently and the code in the main is as follows

main() {
Portal_PermissionServiceSoapBindingStub stub = new Portal_PermissionServiceSoapBindingStub();
stub.checkPermission(10149, 311);
}

public void PermissionServiceSoapBindingStub() {
//constructor
this(null);
java.net.URL url = getURL();
cachedEndpoint = url;
PermissionServiceSoapService service = new PermissionServiceSoapServiceLocator();

java.net.URL url1 = getURL1();
System.out.println("url1:" + url1);
PermissionServiceSoap permissionService = service.getPortal_PermissionService(url1);
((Portal_PermissionServiceSoapBindingStub) permissionService).setUsername("test%40liferay.com");
((Portal_PermissionServiceSoapBindingStub)permissionService).setPassword("ldap");
}


Please let me know if my approach of calling this axis client is wrong.
Hitoshi Ozawa
RE: (401)Unauthorized while accessing web service Liferay 6
29 de marzo de 2012 22:17
Respuesta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensajes: 7990

Fecha de incorporación: 23 de marzo de 2010

Mensajes recientes

Are you generating your own stub instead of using the one provided by Liferay in their SDK?
Hir O
RE: (401)Unauthorized while accessing web service Liferay 6
29 de marzo de 2012 22:53
Respuesta

Hir O

Ranking: Junior Member

Mensajes: 30

Fecha de incorporación: 14 de marzo de 2012

Mensajes recientes

Hi Hitoshi,

Thanks for replying again. I don't know how to use this. I had seen the above link, but in my sdk I didn't found any of the file. Can you please provide me with some other links for this?

Thanks
Hir O
RE: (401)Unauthorized while accessing web service Liferay 6
29 de marzo de 2012 22:55
Respuesta

Hir O

Ranking: Junior Member

Mensajes: 30

Fecha de incorporación: 14 de marzo de 2012

Mensajes recientes

and can't I use this ws through my own stubs?
Bart Simpson
RE: (401)Unauthorized while accessing web service Liferay 6
30 de marzo de 2012 0:17
Respuesta

Bart Simpson

Ranking: Liferay Master

Mensajes: 523

Fecha de incorporación: 29 de agosto de 2011

Mensajes recientes

Hi Hir O,

In case it helps, I was working on something similar, from you post it seems you are using http://127.0.0.1:8080/api/axis/Portal_PermissionService?wsdl

I built the client for Asset Category (
1http://localhost:8080/api/axis/Portlet_Asset_AssetCategoryService?wsdl
) , if you'd generate the client using a java IDE for this one, it will generate "AssetCategoryServiceSoapServiceLocator.java" which contain the url of the form
1http://localhost:8080/api/axis/Portlet_Asset_AssetCategoryService

In order to initialize the permission checker, you need to modify it slightly to the from
1http://localhost:8080/api/secure/axis/Portlet_Asset_AssetCategoryService


And then in the client provide the username / password using:-
1AssetCategoryServiceSoapServiceLocator locator = new AssetCategoryServiceSoapServiceLocator();
2AssetCategoryServiceSoap portlet_Asset_AssetCategoryService = locator.getPortlet_Asset_AssetCategoryService();
3((Portlet_Asset_AssetCategoryServiceSoapBindingStub) portlet_Asset_AssetCategoryService).setUsername("test@liferay.com");
4((Portlet_Asset_AssetCategoryServiceSoapBindingStub) portlet_Asset_AssetCategoryService).setPassword("test");


which should work.

Hope it helps.
Hir O
RE: (401)Unauthorized while accessing web service Liferay 6
30 de marzo de 2012 2:22
Respuesta

Hir O

Ranking: Junior Member

Mensajes: 30

Fecha de incorporación: 14 de marzo de 2012

Mensajes recientes

Hi Paul
I tried this but still the same..

I have "/tunnel-web/" instead of "/api/" in URL.

I tried with both this simple url and merging email ids with URL as well but still it's not working


Please let me know is there are some points to take care of or there is some other approach
Hitoshi Ozawa
RE: (401)Unauthorized while accessing web service Liferay 6
30 de marzo de 2012 2:59
Respuesta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensajes: 7990

Fecha de incorporación: 23 de marzo de 2010

Mensajes recientes

Sorry, I wrote that page some time ago. I think I've included what's needed to build in the sample download. When I have the time, I'll add the information on requirements and on building to the wiki page.

BTW, did you get liferay-portal-dependencies? I think that was required too.
Bart Simpson
RE: (401)Unauthorized while accessing web service Liferay 6
30 de marzo de 2012 3:03
Respuesta

Bart Simpson

Ranking: Liferay Master

Mensajes: 523

Fecha de incorporación: 29 de agosto de 2011

Mensajes recientes

The implementation snippet I gave is for Liferay 6.1 , even if I try to open
1http://127.0.0.1:8080/tunnel-web/axis

it's redirect to
1http://127.0.0.1:8080/api/axis
on browser.

Did you change the access url in service Locator as well? (assuming it's 6.1) it should work.

It's important that in service locator url should be of the form
1http://localhost:8080/api/secure/axis/Portlet_Asset_AssetCategoryService
for 6.1
Smilelws2010 lwz
RE: (401)Unauthorized while accessing web service Liferay 6
28 de enero de 2013 7:37
Respuesta

Smilelws2010 lwz

Ranking: Regular Member

Mensajes: 153

Fecha de incorporación: 16 de diciembre de 2010

Mensajes recientes

Hi Bart,
I have a slightly different question, I have a service builder which is working fine and I can remotely access the service too. But whenever a user tries to hit the service it asks for username, passowrd auhentication. I want to bypass the authentication part while accessing services. Is it possible?

Even if I am logged in at the time of making the service call, when you actually hit the service url on a browser it says "you must log in to area “PortalRealm” on localhost:8080." is there a way to avoid this.
Bart Simpson
RE: (401)Unauthorized while accessing web service Liferay 6
3 de febrero de 2013 21:15
Respuesta

Bart Simpson

Ranking: Liferay Master

Mensajes: 523

Fecha de incorporación: 29 de agosto de 2011

Mensajes recientes

yes, it's possible to access it, better option would be to supply the credentials in client created for the service. I have posted a way to get this done on http://www.liferay.com/community/forums/-/message_boards/message/15037937
Otherwise you will have to change liferay's code to remove the authentication. I'd suggest doing it by passing the credentials.
Smilelws2010 lwz
RE: (401)Unauthorized while accessing web service Liferay 6
5 de febrero de 2013 10:07
Respuesta

Smilelws2010 lwz

Ranking: Regular Member

Mensajes: 153

Fecha de incorporación: 16 de diciembre de 2010

Mensajes recientes

Thanks Bart for the suggestion and redirecting to post. Will have to try out.

I had another question, again related to service builder. My service builder portlet works on tomcat and can access remote services as I said before, but when I deployed the same portlet on WebLogic environment , even the portlet got deployed and the methods are working form within the portlet, I am not able to access the services remotely.

Any idea?

Thanks
Smile
Bart Simpson
RE: (401)Unauthorized while accessing web service Liferay 6
7 de marzo de 2013 1:05
Respuesta

Bart Simpson

Ranking: Liferay Master

Mensajes: 523

Fecha de incorporación: 29 de agosto de 2011

Mensajes recientes

There could be an issue on how the service interface are shared across, and therefore may not be accessible, as sharing libraries is different then how it's done in tomcat. Additionally it also is dependent on your server setup / configuration. Managed servers are more strict in access of shared libraries. It would help to pinpoint the issue if you could share any exception appears on the console.