[GeoNetwork-devel] error in calling java services

Hi,

I am trying to access xml.user.login through the following code in java:

PostMethod postMethod = new PostMethod(gnBaseUrl + “/srv/eng/xml.user.login”);

postMethod.setRequestHeader(“Content-Type”, “application/xml”);

postMethod.setRequestBody(“<?xml version=\"1.0\" encoding=\"UTF-8\"?>”+gnUserName+“”+gnPassword+“”);

HttpClient client = new HttpClient();

int responseStatusCode = client.executeMethod(postMethod);

I am getting response status 302. dev docs mention the error responses will be under 500.

So under what cases can we get 302. anything wrong with above code?
It looks strange as I checked carefully that the GN base url, username and password that I am passing are all correct.

Thanks in advance

Ameet

FYI, We are migrating (slowly) all developer docs to be in Readme.md files in the source code modules. In the future the launching off point will be:

https://github.com/geonetwork/core-geonetwork

It is

  1. Not yet complete
  2. Not yet nicely linked together for each module. But that will improve over time.

Jesse

···

On Sun, Jan 12, 2014 at 1:23 PM, Ameet Chaudhari <ameet.chaudhari@anonymised.com> wrote:

Hi Jesse,

I found the information here:
http://geonetwork-opensource.org/manuals/trunk/eng/developer/xml_services/login_xml_services.html

This being in the trunk, I thought, must have been the most updated of developer manuals.

Thanks a lot though, I’ll update my code accordingly.

Regards
Ameet

On Thu, Jan 9, 2014 at 12:22 PM, Jesse Eichar <jesse.eichar@anonymised.com> wrote:

Hi,

First, can you tell me where you found the information about xml.user.login so I can update it?

2 points:

Point 1:
If you look at

https://github.com/geonetwork/core-geonetwork/blob/develop/web/src/main/webapp/WEB-INF/urlrewrite.xml#L168-168


Systems Programmer
kCube Consultancy Services

You will see that xml.user.login is a deprecated API and now you should use: gnBaseUrl+“j_spring_security_check”

the post data is the same as before.

Point 2:
Spring security is used and on a success there will be a 302 redirection to the last page requested in the session.

A failure will be a 302 redirect to gnBaseUrl+“login.jsp?failure=true”

I admit it is not as clean for code. The way the javascript UIs work is they post the login then use

gnBaseUrl+“srv/eng/xml.info?type=me

To test if the login succeeded.

Jesse

On Wed, Jan 8, 2014 at 5:48 PM, Ameet Chaudhari <ameet.chaudhari@anonymised.com…31…> wrote:

Hi,

I am trying to access xml.user.login through the following code in java:

PostMethod postMethod = new PostMethod(gnBaseUrl + “/srv/eng/xml.user.login”);

postMethod.setRequestHeader(“Content-Type”, “application/xml”);

postMethod.setRequestBody(“<?xml version=\"1.0\" encoding=\"UTF-8\"?>”+gnUserName+“”+gnPassword+“”);

HttpClient client = new HttpClient();

int responseStatusCode = client.executeMethod(postMethod);

I am getting response status 302. dev docs mention the error responses will be under 500.

So under what cases can we get 302. anything wrong with above code?
It looks strange as I checked carefully that the GN base url, username and password that I am passing are all correct.

Thanks in advance

Ameet


Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork