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 = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:com:sap:netweaver:pi:monitoring\">" +
  "   <soapenv:Header/>" +
  "   <soapenv:Body>" +
  "      <urn:getChannelAutomationStatus>" +
  "         <!--Zero or more repetitions:-->" +
  "         <channels name=\"CC_File_Sender\" service=\"BC_Test\" party=\"\">" +
  "         </channels>" +
  "      </urn:getChannelAutomationStatus>" +
  "   </soapenv:Body>" +
  "</soapenv:Envelope>";
  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<ChannelAdminDescriptor> cadL = new ArrayList<ChannelAdminDescriptor>();
  cadL.add(cad);
  for (ChannelAdminDescriptor c : ica.getChannelAutomationStatus(cadL)) {
  System.out.println(c.getName());
  System.out.println(c.getService());
  List<ChannelAdminStatus> status = c.getStatus();
  System.out.println(status.get(0).getActivationState());
  }
  }
}

有用的链接:

Web 服务导航器:http://<host>:<port>/wsnavigator

单一服务管理:http://<host>:<port>/nwa/ssadmin

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

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SAP爱好者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值