Home Answers Viewqa Java-Beginners http Client Authentication

 
 


milind
http Client Authentication
0 Answer(s)      2 years and 4 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="http://9.184.65.219:10038";    
    String UserId="adm";    
    String Password="adm";
    String postTitle="Pls11";

    byte entry[] = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><entry xmlns=\"http://www.w3.org/2005/Atom\"> <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())));

System.out.write(entry);

 // 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: ");
System.out.println(method.getResponseBodyAsString());

}

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

}

output Place Collection URL = http://9.184.65.219:10038/asd/myquic/feed 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'@9.184.65.219:10038

Response status code: 401

Response body:

//-----------------

Thanks and regards, Milind........

View Answers









Related Pages:
http Client Authentication
http Client Authentication  hi friends, i am trying a java API using... authentication problem. can any one please help me to solve this problem. please , please... static void main( String[] args ) throws Exception { String qURL="http
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
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
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://www.roseindia.net/struts/struts2/struts2login.shtml 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...: http://www.roseindia.net/ejb/introduction/j2eedemo.shtml http://www.roseindia.net
Authentication of password - Swing AWT
Authentication of password  System level authentication of password...?????  check out the below link  check out this link http... information. http://www.roseindia.net/java/example/java/swing/ 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: http://www.roseindia.net/jsp/loginbean.shtml
login authentication - Java Beginners
. http://www.roseindia.net/jsp/loginbean.shtml Thanks. Amardeep
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
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
MySQL Client
how to compile C Clint API MySQL C client API ( http://dev.mysql.com... MySQL Client       My Sql Client Engle This all-in-one tool will help you create, manage and edit
MySQL Client
; MySQL how to compile C Clint API MySQL C client API ( http://dev.mysql.com... MySQL Client       My Sql Clint... discusses general principles that are common to most MySQL client programs
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
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
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
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
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
Axis2 client - Axis2 Client example
Axis2 client - Axis2 Client example     Apache Axis2 Client code In this section we will develop client code example... we will write the Web service client code and call the web service.  
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
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
Java Servlet : Http Request Headers
Request Header is a request line text that a HTTP client(eg. web browser)sends to a server together with other request data. HTTP client (e.g. a browser) sends...Java Servlet : Http Request Headers In this tutorial, you will learn how
Chapter 5. Client View of an Entity
Chapter 5. Client View of an EntityPrev Part I. Exam Objectives Next     Chapter 5. Client View of an EntityIdentify correct and incorrect statements or examples about the client
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
thin-client project - Java Interview Questions
thin-client project  what is thin-client project??? Plz help me  Hi Friend, Please visit the following link: http://www.roseindia.net/linux/linux-thin-client-terminals.shtml Hope that it will be helpful for you
Save file on Client Machine - Development process
Save file on Client Machine  Hi my application is running on main server machine and all the users of the application are accessing them as http://boserver:9090/AI where boserver is the name of server machine, now when a client
Java client posting to a servlet - Development process
Java client posting to a servlet  Hi, I would like to create a java client that post to a servlet. I am trying to test out a webserver and would... Hello /LoginServlet For more information on servlets visit to : http
Unable to create web service client in java
Unable to create web service client in java  When i try to create a client for the WSDL http://infml00871:82/MapperWebService/Mapper?wsdl... error as I click Finish button for Client creation: IWAB0014E Unexpected exception
Example of struts2.2.1 client side validation.
Example of struts2.2.1 client side validation. In this example, you will see how to implement client side validation in struts2 application. We  can easily implement client side validation in struts2. If we adds validate="
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
Chapter 2. Client View of a Session Bean
Chapter 2. Client View of a Session BeanPrev ...;Client View of a Session BeanIdentify correct and incorrect statements or examples about the client view of a session bean's local and remote home
How to get client's address in a servlet
How to get client's address in a servlet  ... client's address in a servlet. In this example we have used method getremoteAddr() of the ServletRequest interface which returns IP address of the client
SSL Authentication - JSP-Servlet
SSL Authentication  With the help of a sample code describe the use of SSL Authentication of java clients
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
Open Source proxy
Open Source proxy Open-source HTTP proxies A HTTP proxy is a piece of software that acts as an intermediary between HTTP client software (i.e.... responses from the server, and relays them (possibly modified) to the client. HTTP
who is client
who is client   tell me who is client is management
Authentication in Web Application
Authentication in Web Application   ... and JSP page. You can use any browser to test the application Authentication.... 6.Type the following line in address bar "http://localhost

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.