109 lines
5.0 KiB
Plaintext
109 lines
5.0 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=utf-8" %>
|
||
<%@ page import="org.tempuri.SDK3" %>
|
||
<%@ page import="bpm.eos.shenghong.SKD3_Syn_OutService" %>
|
||
<%@ page import="bpm.eos.shenghong.SKD3_Syn_OutServiceLocator" %>
|
||
<%@ page import="org.tempuri.SDK3Response" %>
|
||
<%@ page import="java.rmi.RemoteException" %>
|
||
<%@ page import="javax.xml.rpc.ServiceException" %>
|
||
<%@ page import="weaver.interfaces.secondev.job.Test2" %>
|
||
<%@ page import="java.util.Map" %>
|
||
<%@ page import="java.util.HashMap" %>
|
||
<%@ page import="org.apache.http.impl.client.*" %>
|
||
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
||
<%@ page import="org.apache.http.client.methods.HttpPost" %>
|
||
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
||
<%@ page import="org.apache.http.message.BasicHeader" %>
|
||
<%@ page import="cn.hutool.core.codec.Base64" %>
|
||
<%@ page import="org.apache.http.entity.*" %>
|
||
<%@ page import="java.nio.charset.Charset" %>
|
||
<%@ page import="org.apache.http.HttpEntity" %>
|
||
<%@ page import="org.apache.http.util.EntityUtils" %>
|
||
<%@ page import="java.io.IOException" %>
|
||
|
||
<%
|
||
String url ="http://podevsrv.shenghongtec.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=SH_EOS&receiverParty=&receiverService=&interface=SKD3_Syn_Out&interfaceNamespace=urn:shenghong:eos:bpm";
|
||
|
||
String input ="{\"sysName\": \"SAP_DFSH\", \"returnUrl\": \"%DM_BC%/NNForm/api/Process/GetXiangMuView\",\"processName\": \"HX_TY_ZPRCDJB\", \"dataId\": \"SSQ202308030001\",\"title\": \"江苏国望高科纤维有限公司-张三\",\"initiatorName\": \"85010888\", \"GongSi\": \"江苏国望高科纤维有限公司\", \"XingMing\": \"张三\",\"XingBie\": \"男\",\"MinZhu\": \"汉族\",\"JiGuan\": \"江苏省\",\"ChuShengNY\": \"1996-07-01\",\"ZhengZhiMM\": \"群众\",\"ShenFenZH\": \"14052419761114803Y\",\"LianXiDH\": \"13888888888\",\"ShenGao\": \"170\",\"TiZhong\": \"75\", \"ZhuanYe\": \"人力资源专业\",\"XueLi\": \"本科\",\"BiYeYX\": \"西安交通大学\",\"JiaTingDZ\": \"云南省德宏傣族景颇族\",\"XueXiJL\": \"2000年6月-2004年7月 交通大学\",\"GongZuoJL\": \"2000年6月-2004年7月 盛虹化纤\",\"YingPingGW\": \"人资主任\",\"ZhaoPinZYGH\": \"85010888\",\"DangAnGID\": \"3357199313267944455\",\"ZhaoPinZY\": \"85010888\",\"ShenQingRBuMenID\": \"80109000\",\"ShenQingRGongSiID\": \"80100000\",\"GongSiMC\": \"江苏国望高科纤维有限公司\",\"BuMenMC\": \"数智化部\"}";
|
||
|
||
String xml="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\">\n" +
|
||
" <soapenv:Header/>\n" +
|
||
" <soapenv:Body>\n" +
|
||
" <tem:SDK3>\n" +
|
||
" <tem:json>"+input+"</tem:json>\n" +
|
||
" </tem:SDK3>\n" +
|
||
" </soapenv:Body>\n" +
|
||
"</soapenv:Envelope>";
|
||
|
||
String usr_pwd = "po_sender:posender0807" ;
|
||
String soapAction = "";
|
||
|
||
doPostSoap(url,xml,soapAction,usr_pwd);
|
||
|
||
%>
|
||
<%!
|
||
|
||
|
||
public Map<String,String> doPostSoap(String url, String soapXml, String soapAction, String userpass) throws Exception
|
||
{
|
||
|
||
Map<String,String> msgMap = new HashMap<String,String>();
|
||
|
||
System.out.println("url:"+url);
|
||
System.out.println("soapXml:"+soapXml);
|
||
System.out.println("soapAction:"+soapAction);
|
||
System.out.println("userpass:"+userpass);
|
||
|
||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
|
||
HttpPost httpPost = new HttpPost(url);
|
||
//设置请求和传输超时时间
|
||
String result = "";
|
||
CloseableHttpResponse response = null;
|
||
try {
|
||
httpPost.setHeader("Content-Type", "text/xml;charset=UTF-8");
|
||
httpPost.setHeader("SOAPAction", soapAction);
|
||
httpPost.addHeader(new BasicHeader("Authorization", "Basic " + new String(Base64.encode(userpass.getBytes()))));
|
||
StringEntity data = new StringEntity(soapXml, Charset.forName("UTF-8"));
|
||
System.out.println("data:"+data.toString());
|
||
httpPost.setEntity(data);
|
||
response = closeableHttpClient.execute(httpPost);
|
||
HttpEntity httpEntity = response.getEntity();
|
||
if (httpEntity != null)
|
||
{
|
||
result = EntityUtils.toString(httpEntity, "UTF-8");
|
||
System.out.println("result:"+result);
|
||
if(!"".equals(result))
|
||
{
|
||
result = result.replace("<","<").replace(">",">");
|
||
|
||
}else{
|
||
msgMap.put("code","-100");
|
||
msgMap.put("sqlcode","-100");
|
||
msgMap.put("description","ERP接口返回值为空");
|
||
}
|
||
}else{
|
||
msgMap.put("code","-200");
|
||
msgMap.put("sqlcode","-200");
|
||
msgMap.put("description","ERP接口返回值为空");
|
||
}
|
||
} catch (Exception e)
|
||
{
|
||
e.printStackTrace();
|
||
System.out.println("e:"+e);
|
||
msgMap.put("code","-200");
|
||
msgMap.put("sqlcode","-200");
|
||
msgMap.put("description","ERP接口调用异常:"+e);
|
||
} finally {
|
||
if (response != null) {
|
||
try {
|
||
EntityUtils.consume(response.getEntity());
|
||
} catch (IOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
return msgMap;
|
||
}
|
||
|
||
|
||
%> |