Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
(401)Unauthorized while accessing web service Liferay 6 Hir O March 29, 2012 8:58 PM
RE: (401)Unauthorized while accessing web service Liferay 6 Hitoshi Ozawa March 29, 2012 9:12 PM
RE: (401)Unauthorized while accessing web service Liferay 6 Hir O March 29, 2012 10:05 PM
RE: (401)Unauthorized while accessing web service Liferay 6 Hitoshi Ozawa March 29, 2012 10:17 PM
RE: (401)Unauthorized while accessing web service Liferay 6 Hir O March 29, 2012 10:53 PM
RE: (401)Unauthorized while accessing web service Liferay 6 Hitoshi Ozawa March 30, 2012 2:59 AM
RE: (401)Unauthorized while accessing web service Liferay 6 Hir O March 29, 2012 10:55 PM
RE: (401)Unauthorized while accessing web service Liferay 6 Bart Simpson March 30, 2012 12:17 AM
RE: (401)Unauthorized while accessing web service Liferay 6 Hir O March 30, 2012 2:22 AM
RE: (401)Unauthorized while accessing web service Liferay 6 Bart Simpson March 30, 2012 3:03 AM
RE: (401)Unauthorized while accessing web service Liferay 6 Smilelws2010 lwz January 28, 2013 7:37 AM
RE: (401)Unauthorized while accessing web service Liferay 6 Bart Simpson February 3, 2013 9:15 PM
RE: (401)Unauthorized while accessing web service Liferay 6 Smilelws2010 lwz February 5, 2013 10:07 AM
RE: (401)Unauthorized while accessing web service Liferay 6 Bart Simpson March 7, 2013 1:05 AM
RE: (401)Unauthorized while accessing web service Liferay 6 suneel kumar January 27, 2016 4:52 AM
RE: (401)Unauthorized while accessing web service Liferay 6 suneel kumar January 27, 2016 8:31 PM
Hir O
(401)Unauthorized while accessing web service Liferay 6
March 29, 2012 8:58 PM
Answer

Hir O

Rank: Junior Member

Posts: 30

Join Date: March 14, 2012

Recent Posts

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
March 29, 2012 9:12 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

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
March 29, 2012 10:05 PM
Answer

Hir O

Rank: Junior Member

Posts: 30

Join Date: March 14, 2012

Recent Posts

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
March 29, 2012 10:17 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

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
March 29, 2012 10:53 PM
Answer

Hir O

Rank: Junior Member

Posts: 30

Join Date: March 14, 2012

Recent Posts

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
March 29, 2012 10:55 PM
Answer

Hir O

Rank: Junior Member

Posts: 30

Join Date: March 14, 2012

Recent Posts

and can't I use this ws through my own stubs?
Bart Simpson
RE: (401)Unauthorized while accessing web service Liferay 6
March 30, 2012 12:17 AM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 524

Join Date: August 29, 2011

Recent Posts

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
March 30, 2012 2:22 AM
Answer

Hir O

Rank: Junior Member

Posts: 30

Join Date: March 14, 2012

Recent Posts

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
March 30, 2012 2:59 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

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
March 30, 2012 3:03 AM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 524

Join Date: August 29, 2011

Recent Posts

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
January 28, 2013 7:37 AM
Answer

Smilelws2010 lwz

Rank: Regular Member

Posts: 160

Join Date: December 16, 2010

Recent Posts

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
February 3, 2013 9:15 PM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 524

Join Date: August 29, 2011

Recent Posts

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
February 5, 2013 10:07 AM
Answer

Smilelws2010 lwz

Rank: Regular Member

Posts: 160

Join Date: December 16, 2010

Recent Posts

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
March 7, 2013 1:05 AM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 524

Join Date: August 29, 2011

Recent Posts

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.
suneel kumar
RE: (401)Unauthorized while accessing web service Liferay 6
January 27, 2016 4:52 AM
Answer

suneel kumar

Rank: New Member

Posts: 14

Join Date: September 14, 2015

Recent Posts

remoteUser = "test";
password = "test";
String url = "http://" + remoteUser + ":" + password + "@localhost:8080/api/secure/axis/" + serviceName;
when i run this url i got this exception. can anybody help me?

Jan 27, 2016 6:16:25 PM org.apache.axis.utils.JavaUtils isAttachmentSupported
WARNING: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (401)Unauthorized
faultActor:
faultNode:
faultDetail:
{}:return code: 401
<html><head><title>Apache Tomcat/7.0.27 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-coloremoticon525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-coloremoticon525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-coloremoticon525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-coloremoticon525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>This request requires HTTP authentication ().</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.27</h3></body></html>
{http://xml.apache.org/axis/}HttpErrorCode:401

(401)Unauthorized
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.liferay.client.soap.portal.service.http.Portal_CompanyServiceSoapBindingStub.getCompanyByVirtualHost(Portal_CompanyServiceSoapBindingStub.java:495)
at Org.main(Org.java:34)
suneel kumar
RE: (401)Unauthorized while accessing web service Liferay 6
January 27, 2016 8:31 PM
Answer

suneel kumar

Rank: New Member

Posts: 14

Join Date: September 14, 2015

Recent Posts

Hi all,
Yessssss.......... I got that issue....

Just change the authentication type as ScreenName in portal-ext.properties file and control panel-->Portal setting-->Authentication

company.security.auth.type=screenName