Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Answers Viewqa Java-Beginners http Client Authentication

Have Programming Question? Ask it here!

http Client Authentication
0 Answer(s)      3 years and 8 months ago
Posted in : Java Beginners

hi friends,

i am trying a java API using HTTPCLient post method.  in which i am getting output having some authentication problem. can any one please help me to solve this problem.

please , please help me.. waiting for reply.

Thanks in advance.

This is what the PROGRAM

import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;

public class sms {

public static void main( String[] args ) throws Exception  {

 String qURL="";    
    String UserId="adm";    
    String Password="adm";
    String postTitle="Pls11";

    byte entry[] = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><entry xmlns=\"\"> <title type=\"text\"> "+postTitle+" </title></entry>").getBytes();

String placeurl = qURL+"/asd/myquic"+"/feed";

 try {
    System.out.println("\n Place Collection URL = "+ placeurl);

HttpClient client = new HttpClient();
PostMethod method = new PostMethod( placeurl );

 // Configure the form parameters

  method.addParameter( "CONTENT-TYPE", "application/atom+xml" );
  method.addParameter( "CONTENT-LENGTH", new Integer(entry.length).toString() );
  method.addParameter( "Host", "localhost");
  method.addParameter( "User-Agent", "Thingio/1.0" );
  method.addParameter( "Keep-Alive", "header");
  method.addParameter( "Authorization", "Basic " + (new  sun.misc.BASE64Encoder().encode((UserId+":"+Password).getBytes())));


 // Execute the POST method
int statusCode = client.executeMethod( method );

System.out.println("\n Response status code: " + statusCode);

// Display response
System.out.println("\n Response body: ");


 catch( Exception e ) {
    System.err.println ( "\n Exception...\n" + e ) ;


Place Collection URL =
<?xml version="1.0" encoding="UTF-8"?><entry xmlns="">
Pls11 Jan 10, 2011 3:17:19 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
Jan 10, 2011 3:17:19 PM org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
INFO: No credentials available for BASIC 'Atom'@

Response status code: 401

Response body: 
Thanks and regards,

View Answers

Related Tutorials/Questions & Answers:
http Client Authentication
http Client Authentication  hi friends, i am trying a java API... authentication problem. can any one please help me to solve this problem. please... ) throws Exception { String qURL=""; String
Spring Security HTTP basic authentication
Spring Security HTTP basic authentication In this section, you will learn about the HTTP basic authentication in Spring Security. You can configure HTTP... Security HTTP basic authentication configuration--> <http> <intercept
How to fireup HTTP request from JavaFX Client
How to fireup HTTP request from JavaFX Client  Please tel me how do I can fire HTTP post request from an JavaFX client. Sceneario: I've an JavaFX... i've working version of JSP Code to handle HTTP post request tested by posting
Basic authentication
the client's built in authentication mechanism. In java programming language... Basic authentication       Basic authentication is the process through which a web server authenticates
HTTP Authentication With PHP
HTTP Authentication with PHP: The HTTP Authentication is available when... to send a message (for authentication) to the client side (browser... for authentication. $_SERVER and $HTTP_SERVER_VARS contains these predefined
Authentication - JavaMail
Authentication program in Java  How to write a program in Java for user authentication
Authentication in Servlets
Authentication in Servlets  What are different Authentication options available in Servlets
Authentication - Struts
Authentication  Hello everybody, How to provide high level authentication in struts application
Login authentication
Login authentication  i want d code for login authentication from mysql database on the same pc using swings
Login authentication
Login authentication  i want d code for login authentication from mysql database on the same pc using swings
gmail authentication
browser window it asks for authentication how it is possible if anybody knows plz tell... request Authentication done using Session If you signout and paste URL It Ask
Struts Login Authentication
Struts Login Authentication  Hi Sir, Am doing a project in a struts 1.2,i want login authentication code fro that, only authenticated user can...: http
Sending email without authentication
Sending email without authentication  Hi sir, Am doing a project in JSP, in that i want to send mail without any authentication of password so send...:
iphone nsurlrequest authentication
iphone nsurlrequest authentication   How to authenticate a form in iPhone Application
windows authentication with hibernate - Hibernate
windows authentication with hibernate  Does anyone know how to setup a datasource for SQL Server that uses Windows authentication instead of SQL Server mixed mood authentication? Is it possible with hibernate framwork? Thanks
SSL Authentication - JSP-Servlet
SSL Authentication  With the help of a sample code describe the use of SSL Authentication of java clients
Retrieve HTTP Request Headers using JSP
the request headers. When a HTTP client sends a request, it is required to supply GET... Retrieve HTTP Request Headers using JSP   ...-Alive value or gets a  request line indicating HTTP 1.1, it may
login authentication - Java Beginners
login authentication  i 've designed the jsp page for login. now i need to connect it with the bean and do authentication for the login for the "register" table in mysql. can anybody help me with the code immediately
Authentication of password - Swing AWT
Authentication of password  System level authentication of password...?????  check out the below link  check out this link http... information. Thanks
JDbc Login Authentication
JDbc Login Authentication  Pease Please.. Send Me one Login Authentication Using ComboBox.From Servlet and jsp with sessions I am new to sessions... the following link:
who is client
who is client   tell me who is client is management
user authentication code in php - PHP
user authentication code in php  Hi, Can you please send me a user authentication code in php? or just post the guidelines to authenticate a user. Thanks
Client Interview
Client Interview  Hi, I am kumar i am having client round in polaries client is a BANK. how to face client interview. what are the expected questions from CITI
Login Authentication and session in JSP - JSP-Servlet
Login Authentication and session in JSP  Hi, I am creating an small application in JSP,in which i need to check user authentication and session... with this. Thank you  Hi Friend, Please visit the following link: http
login authentication - Java Beginners
. Thanks. Amardeep
Thin client
Thin client  What is a thin client?   A thin client is a lightweight interface to the application that does not have such operations like query databases, execute complex business rules, or connect to legacy
in php What the code is to be written for Authentication with Session Control
in php What the code is to be written for Authentication with Session Control  in php What the code is to be written for Authentication with Session Control
Login authentication & mysql - Java Beginners
Login authentication & mysql  Hi , Could you guide or provide sample coding for the following scenerio. I need to code authentication for user... Authentication with MySql using Java Swing: 1)Create a java class
Rmi client
Rmi client  Sir i just created client and server following the RMI rule, its running properly in the localhost, when i am trying to run the program in the different machine its not working, i changed the ip also, when i copied
Specifying an Authentication Mechanism in the Deployment Descriptor
In this section, you will learn how to specify an authentication mechanism in the deployment descriptor
send without authentication mail using java - JavaMail
send without authentication mail using java  Dear All, I am tring to send simple mail without authentication using java. is it possible, could i send email without authentication. I have written following code. public
Problem with Instead of using http://localhost:8080 using http://{ipaddress}:8080
Problem with Instead of using http://localhost:8080 using http://{ipaddress... Object to access the java class and display through flex. It works if I ues http... Address instead of localhost , login page is opening http://{ipaddress}:8080
HTTP Post PHP  HTTP post method example in PHP
Java Client Application
Java Client Application  Java Client Application
error "HTTP Status 500"
error "HTTP Status 500"  How to solve this error "HTTP Status 500
http header content length
http header content length  How to check the request header content length in HTTP
Client side refresh
Client side refresh  What is client side refresh?   The standard HTTP protocols ways of refreshing the page, which is normally supported by all browsers. <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/servlet/MyServlet
Login Authentication using existing Active Directory.
Login Authentication using existing Active Directory.  I need jsp code for login authentication of username and password using already existing Active Directory. Here no need to create active directory.The JSP code should
HTTP Protocol
HTTP Protocol          HTTP Protocol stands for Hyper Text Transfer Protocol. It is the protocol used to convey information of World Wide Web (WWW). HTTP protocol
Java Glossary : Authentication
Java Glossary : Authentication       Authentication is the process of ensuring to some in order... key.  A web authentication where a web page includes a dialog box having
Difference between http and https
Difference between http and https  Difference b/w HTTP and HTTPS please provide answer in tabular form.   Hi Friend, Differences: 1)HTTP... and receiving information across the Internet where as HTTPS is secure http, which
JMeter HTTP request example
JMeter HTTP request example  Concerning: how do I set path? also what do i need to do to get the helloworld servlet work? Thanks in advance
HTTP Status 404 -
HTTP Status 404 -   HTTP Status 404 - type Status report message description The requested resource () is not available. Apache Tomcat/5.5.31 how to rectify the above error
HTTP_POST_VARS is deprecated
HTTP_POST_VARS is deprecated  HTTPPOSTVARS is deprecated. Which function to be used? Thanks   Hi, You should use: $id=$_GET["id"]; or $id=$_POST["id"]; thanks
Java HTML Client Application
Java HTML Client Application  Java HTML Client Application
Java Client Application example
Java Client Application example  Java Client Application example
HTTP Status 500 -
HTTP Status 500 -   Hi, I am new to jsp... Installed Tomcat 5.5.... wrote. i can see these errors... HTTP Status 500 - type Exception report... of your tomcat. 8)Open your browser and type the following url: http://localhost
Client's Data with Axis2 and Java
Client's Data with Axis2 and Java  Hello everyone, I am studying... client's data? First of all back-end will be build in Java(will try to implement some... worked with Eclipse(duh) there is very nice feature of generating server/client
Error : http status 500?
Error : http status 500?  hello sir, am using netbeans6.7.1 version i implemented one program i.e web application ..when am excuting this one i got one error http status 500...please solve this error ..when did i mistakn