JAVA如何调用SAP PI PO 发布的Web Services接口

请使用 SoapUI 在沙盒中测试这些 Web 服务,因为这些 Web 服务的 SAP 文档很少。SAP甚至可能在未来添加更多的Web服务。

SAP PO Web Services

package com.web;
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.net.PasswordAuthentication;
import java.net.URL;
public class TestMain {
  public static void main(String[] args) throws Exception {
  Authenticator.setDefault(new Authenticator() {
  // This method is called when a password-protected URL is accessed
  @Override
  protected PasswordAuthentication getPasswordAuthentication() {
  return new PasswordAuthentication("UserId", "Password".toCharArray());
  }
  });
  HttpURLConnection con = (HttpURLConnection) new URL("http://Server:50200/ChannelAdminService/ChannelAdmin").openConnection();
  con.setRequestMethod("POST");
  con.setRequestProperty("content-type", "text/xml");
  con.setDoOutput(true);
  String s = "" +
  "   " +
  "   " +
  "      " +
  "         " +
  "         " +
  "         " +
  "      " +
  "   " +
  "";
  con.getOutputStream().write(s.getBytes());
  byte[] b = new byte[con.getInputStream().available()];
  con.getInputStream().read(b);
  System.out.println(new String(b));
  }
}

Java Language (using WSDL)

package com.web;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.ws.BindingProvider;
import com.sap.netweaver.pi.monitoring.ChannelAdminDescriptor;
import com.sap.netweaver.pi.monitoring.ChannelAdminStatus;
import com.sap.pi.monitoring.channel.ChannelAdminService;
import com.sap.pi.monitoring.channel.GetChannelAutomationStatusFault;
import com.sap.pi.monitoring.channel.IChannelAdmin;
public class MyMain {
  public static void main(String[] args) throws MalformedURLException, GetChannelAutomationStatusFault {
  IChannelAdmin ica = new ChannelAdminService().getChannelAdminPort();
  BindingProvider bp = (BindingProvider) ica;
  bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "UserId");
  bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "Password");
  ChannelAdminDescriptor cad = new ChannelAdminDescriptor();
  cad.setName("CC_File_Sender");
  cad.setService("BC_Test");
  cad.setParty("");
  List cadL = new ArrayList();
  cadL.add(cad);
  for (ChannelAdminDescriptor c : ica.getChannelAutomationStatus(cadL)) {
  System.out.println(c.getName());
  System.out.println(c.getService());
  List status = c.getStatus();
  System.out.println(status.get(0).getActivationState());
  }
  }
}

有用的链接:

Web 服务导航器:http://:/wsnavigator

单一服务管理:http://:/nwa/ssadmin

JAVA如何调用SAP PI PO 发布的Web Services接口_第1张图片

你可能感兴趣的:(SAP,PO,PI,系统接口集成,SAP,Web,Service,JAVA,PI,PO,SOAP,JAVA,PO,SOAP,SAP,PI,PO,接口调用)