on 03-08-2011 8:08 PM
I am writing a java code to call the http URL to start/stop the communication channel. I am getting 401 (Unauthorized) HTTP response. However, I am able start and stop the channel via browser with the HTTP URL.
How do invoke the URL and pass the user name/password in Java??
Your help will be greatly appreciated.
Thanks,
Karma
Hi,
Import theses classes and add the below code
import java.net.Authenticator;
import java.net.PasswordAuthentication;
add this class in ur java code to athenticate ur PI server
static class MyAuthenticator extends Authenticator
{
public PasswordAuthentication getPasswordAuthentication()
{
System.err.println("Logging in for " + getRequestingHost()+" which is a "+getRequestorType()+" Having "+getRequestingScheme()+" Authentication");
return (new PasswordAuthentication("username", "password".toCharArray()));
}
}
And add this line in ur main function
Authenticator.setDefault(new MyAuthenticator());
Hope it helps,
Anand
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karma,
check this link, JSP is used to create a web page with options on start/stop channel externally
http://wiki.sdn.sap.com/wiki/display/XI/ExternallyControllingtheCommunicationChannel
Regards,
Aravind
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>Your help will be greatly appreciated.
For accessing channel information you might have to use integration directory API in your java code. Use my reply in this thread
>>How do invoke the URL and pass the user name/password in Java??
Use Java URL class and write the program as given in the link. Provide user name and password in the url string query.
Simple code snippet...
http://www.exampledepot.com/egs/java.net/post.html
Hope that helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.