Skip to Content
avatar image
Former Member

Java Code to Start/Stop communication channel externally

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Mar 08, 2011 at 08:28 PM

    >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

    accessing-channel-schedule-info

    >>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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 09, 2011 at 03:08 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 09, 2011 at 05:13 AM

    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

    Add comment
    10|10000 characters needed characters exceeded