请求报文
返回报文
1.新建soapclien工具类,也可以自己拼接请求字符串,这里用的事通过SOAPPart构建拼接,对于返回的xml报文我们需要转义
package com.hrsj.dp.mcc.account.esb;
import com.hrsj.dp.mcc.account.esb.model.ESBReturn;
import com.hrsj.dp.mcc.account.esb.model.EsbServiceForERPTaskBean;
import com.hrsj.dp.mcc.account.esb.model.EsbServiceTaskReturnBean;
import com.hrsj.dp.mcc.account.esb.utils.EsbTaskUtils;
import com.hrsj.dp.mcc.account.esb.utils.XStreamXmlBeanUtil;
import org.apache.commons.lang3.StringEscapeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.bind.JAXBException;
import javax.xml.soap.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
/**
* @Author:pengfusong
* @Description:
* @Date: Create in 10:21 2023/10/26
* @Modified by :
*/
public class SOAPClientForESB_ERP {
private static final Logger log = LoggerFactory.getLogger(SOAPClient.class);
private static final String NAME_SPACE_FOR_WSSE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
private static final String NAME_SPACE_FOR_CUX = "http://xmlns.oracle.com/apps/cux/soaprovider/plsql/cux_10_ws_server_prg/";
private static final String NAME_SPACE_FOR_INV = "http://xmlns.oracle.com/apps/cux/soaprovider/plsql/cux_10_ws_server_prg/invokefmsws/";
private static final String NAME_SPACE_FOR_PASSWORD = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText";
/** 通用方法 */
public static ESBReturn putXmlSoap(EsbServiceForERPTaskBean esbServiceTaskBean, String xmlStr,
String urlString) {
log.info("开始调用接口");
// EsbServiceTaskReturnBean result = new EsbServiceTaskReturnBean();
ESBReturn result= new ESBReturn();
try {
/** 创建连接 */
SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnFactory.createConnection();
/** 创建消息对象 */
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
// message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8");
/** 创建soap消息主体 */
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("cux"