http Client Authentication



Share on Google+Share on Google+

http Client Authentication
0 Answer(s)      6 years and 5 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 [email protected]:10038

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
java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient
java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient  Hi, I have a program which is developed using the http client. It is giving following error: java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient
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
noclassdeffounderror: org/apache/http/client/methods/httpurirequest
noclassdeffounderror: org/apache/http/client/methods/httpurirequest  Hi, One of my application is throwing following error: noclassdeffounderror: org/apache/http/client/methods/httpurirequest How to resolve this? Thanks  
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 in Servlets
Authentication in Servlets  What are different Authentication options available in Servlets
Authentication - JavaMail
Authentication program in Java  How to write a program in Java for user authentication
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
Authentication - Struts
Authentication  Hello everybody, How to provide high level authentication in struts application
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
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...:
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
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
http program
http program  how to write basic http program in java
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