1.下载 Axis 下载地址 http://axis.apache.org/axis2/java/core/download.html
解压后进入bin目录
2.访问sap接口地址,将xml下载下来,保存为wsdl格式
3.在地址栏输入cmd,进入命令行,执行:
WSDL2Java -uri vsens.wsdl -p com.jeeplus.modules.fix.service.vsens -o vsens
vsens.wsdl为你下载下来的xml,com.jeeplus.modules.fix.service.vsens为你将把文件放在项目哪个目录下的路径,vsens为自定义命名。
public static List<FixVsensResponse> getVsensInfo(String date){
List<FixVsensResponse> fixVsensResponseList = new ArrayList<>();
try {
Date dateS = new Date();
String timestamp = DateUtils.formatDate(dateS,"yyyy-MM-dd_HH:mm:ss");
String transId = DateUtils.formatDate(dateS,"yyyyMMddHHmmss") + StringUtils.generateRandom(true,6);
SI_SEARCH_PRODUCTServiceStub serviceStub = new SI_SEARCH_PRODUCTServiceStub();
HttpTransportPropertiesImpl.Authenticator auth = new HttpTransportPropertiesImpl.Authenticator();
auth.setUsername(userName);
auth.setPassword(password);
serviceStub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, auth);
SI_SEARCH_PRODUCTServiceStub.Z_FWS_SO_SEARCH_BAK searchBak = new SI_SEARCH_PRODUCTServiceStub.Z_FWS_SO_SEARCH_BAK();
SI_SEARCH_PRODUCTServiceStub.ZFWSTRANSFERINFOIN zfwstransferinfoin = new SI_SEARCH_PRODUCTServiceStub.ZFWSTRANSFERINFOIN();
SI_SEARCH_PRODUCTServiceStub.ZFWSENCRYPTION zfwsencryption = new SI_SEARCH_PRODUCTServiceStub.ZFWSENCRYPTION();
SI_SEARCH_PRODUCTServiceStub.APP_ID_type1 appIdType1 = new SI_SEARCH_PRODUCTServiceStub.APP_ID_type1();
appIdType1.setAPP_ID_type0(appId);
zfwsencryption.setAPP_ID(appIdType1);
SI_SEARCH_PRODUCTServiceStub.TIMESTAMP_type1 timestampType1 = new SI_SEARCH_PRODUCTServiceStub.TIMESTAMP_type1();
timestampType1.setTIMESTAMP_type0(timestamp);
zfwsencryption.setTIMESTAMP(timestampType1);
SI_SEARCH_PRODUCTServiceStub.TRANS_ID_type1 transIdType1 = new SI_SEARCH_PRODUCTServiceStub.TRANS_ID_type1();
transIdType1.setTRANS_ID_type0(transId);
zfwsencryption.setTRANS_ID(transIdType1);
SI_SEARCH_PRODUCTServiceStub.TOKEN_type1 tokenType1 = new SI_SEARCH_PRODUCTServiceStub.TOKEN_type1();
String md5str = DigestUtils.md5Hex("APP_ID" + appId + "TIMESTAMP" + timestamp + "TRANS_ID" + transId).toUpperCase();
//md5str = DigestUtils.md5Hex((appId + timestamp + transId).getBytes("gbk")).toUpperCase();
tokenType1.setTOKEN_type0(md5str);
zfwsencryption.setTOKEN(tokenType1);
zfwstransferinfoin.setENCRYPTION(zfwsencryption);
SI_SEARCH_PRODUCTServiceStub.ZFWSINPUTINFO zfwsinputinfo = new SI_SEARCH_PRODUCTServiceStub.ZFWSINPUTINFO();
SI_SEARCH_PRODUCTServiceStub.LIFNR_type3 lifnrType3 = new SI_SEARCH_PRODUCTServiceStub.LIFNR_type3();
lifnrType3.setLIFNR_type2(appId);
zfwsinputinfo.setLIFNR(lifnrType3);
SI_SEARCH_PRODUCTServiceStub.UPDATE_DATE_type1 updateDateType1 = new SI_SEARCH_PRODUCTServiceStub.UPDATE_DATE_type1();
//查询条件 日期
updateDateType1.setUPDATE_DATE_type0(date);
zfwsinputinfo.setUPDATE_DATE(updateDateType1);
zfwstransferinfoin.setINPUTINFO(zfwsinputinfo);
searchBak.setTRANSFERINFO_IN(zfwstransferinfoin);
SI_SEARCH_PRODUCTServiceStub.Z_FWS_SO_SEARCH_BAKResponse zFwsSoSearchBakResponse = serviceStub.sI_SEARCH_PRODUCT(searchBak);
SI_SEARCH_PRODUCTServiceStub.ZFWSTRANSFERINFOOUT zfwstransferinfoout = zFwsSoSearchBakResponse.getTRANSFERINFO_OUT();
if(zfwstransferinfoout!=null){
if("T".equals(zfwstransferinfoout.getSERVICE_FLAG().getSERVICE_FLAG_type0())){
for (SI_SEARCH_PRODUCTServiceStub.ZSFWSSALESORDER zsfwssalesorder:zfwstransferinfoout.getSALESORDER().getItem()) {
String phone = zsfwssalesorder.getRESERVED_2().getRESERVED_2_type0();
String serialNumber = zsfwssalesorder.getSERIALNUMBER().getSERIALNUMBER_type0();
FixVsensResponse fixVsensResponse = new FixVsensResponse();
fixVsensResponse.setPhone(phone);
fixVsensResponse.setSerialNumber(serialNumber);
fixVsensResponseList.add(fixVsensResponse);
}
}
}
}catch (Exception e){
e.printStackTrace();
}
return fixVsensResponseList;
}
参考资料:https://blog.csdn.net/qq_36907589/article/details/97389398