Skip to Content
avatar image
Former Member

Communication channels wouldn't start through external program

Hi All,

I'm new to SAP. I've designed a Java background program which starts the provided communication channels. The program will be triggered when a file is placed in a particular location in the system. From java end the program is working well and perfect. Even the Http requests perform fine and even I get a response XML DTD or XSD but the communications channels won't start. I'm not able to understand if the fault is with my program or with the SAP system.

I'll now paste the code which triggers the http requests to start/stop a communciation. Kindly help with this. Correct me If I am wrong.

Program:

package test;

import java.awt.Desktop;

import java.io.IOException;

import java.net.URI;

import java.net.URISyntaxException;

public class Browser{

String urlstart = "http://host:port/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=Communication Channel Name&action=start";

String urlstop = "http://host:port/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=Communication Channel Name&action=stop";

//String urlstatus = "http://host:port/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=Communication Channel Name&action=status";

public boolean openBrowser() throws InterruptedException{

boolean flag= false;

if(Desktop.isDesktopSupported()){

Desktop desktop = Desktop.getDesktop();

try {

desktop.browse(new URI(urlstart));

Thread.sleep(2000);

//desktop.browse(new URI(urlstart1));

System.out.println("Desktop Supports --> OpenBrowser");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (URISyntaxException e){

e.printStackTrace();

}

}else{

Runtime runtime = Runtime.getRuntime();

try {

Process p= runtime.exec("C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe \""+urlstart+"");

System.out.println("Desktop doesn't Support --> OpenBrowser");

Thread.sleep(2000);

p.waitFor();

p.destroy();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

return flag;

}

public boolean openBrowserStop() throws InterruptedException{

boolean flag= false;

if(Desktop.isDesktopSupported()){

Desktop desktop = Desktop.getDesktop();

try {

desktop.browse(new URI(urlstop));

Thread.sleep(2000);

// desktop.browse(new URI(urlstop1));

System.out.println("Desktop Supports --> OpenBrowserStop");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (URISyntaxException e){

e.printStackTrace();

}

}else{

Runtime runtime = Runtime.getRuntime();

try {

//runtime.exec("xdg-open " + urlstart)

Process p= runtime.exec("C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe \""+urlstop+"");

System.out.println("Desktop doesn't Support --> OpenBroswerStop");

Thread.sleep(2000);

p.waitFor();

p.destroy();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

return flag;

}

}

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Mar 31, 2016 at 10:54 AM

    Hi Gopi,

    You can use communication channel web service to stop and start the channels as shown in the below blog.

    SAP PI : Start/Stop Communication Channel using Webservice

    Regards,

    Praveen.

    Add comment
    10|10000 characters needed characters exceeded