soap问题 很急

guicaizhou guicaizhou 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
// 创建连接
// ==================================================
SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnFactory.createConnection();

// 创建消息对象
// ===========================================
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
// message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "gb2312");

// 创建soap消息主体==========================================
SOAPPart soapPart = message.getSOAPPart();// 创建soap部分
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPHeader soapHeader = envelope.getHeader();
SOAPBody body = envelope.getBody();
// 根据要传给mule的参数,创建消息body内容。具体参数的配置可以参照应用集成接口技术规范1.1版本
// =====================================
SOAPElement bodyElement = body.addChildElement(envelope.createName("LotteryBalanceQuery", "m", "http://LotteryBalanceQuery.tydic.com"));
SOAPElement bodyElement1 = bodyElement.addChildElement("in0");
SOAPElement bodyElement2 = bodyElement1.addChildElement("entry");
SOAPElement bodyElement3 = bodyElement1.addChildElement("entry");
SOAPElement bodyElement4 = bodyElement1.addChildElement("entry");

bodyElement2.addChildElement("key").addTextNode("nStaffId");
bodyElement2.addChildElement("value").addTextNode("100097");

bodyElement3.addChildElement("key").addTextNode("nLantId");
bodyElement3.addChildElement("value").addTextNode("551");

bodyElement4.addChildElement("key").addTextNode("sServiceNbr");
bodyElement4.addChildElement("value").addTextNode("15305510283");

// Save the message
message.saveChanges();
// 打印客户端发出的soap报文,做验证测试
message.writeTo(System.out);


最后一句报错 不知道什么原因
...全文
评论 2
收藏 已收藏
分享
返回顶部
guicaizhou
Java 51,407 成员 86,132 内容