cancel
Showing results for 
Search instead for 
Did you mean: 

Java Code to Start/Stop communication channel externally

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>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