---
title: "SOAPConnection调用WebService"
author: "showcup"
date: "2010-09-03T10:58:29Z"
tags: []
categories: ["编程语言"]
slug: "soapconnection-webservice"
draft: false
lastmod: "2010-09-03T14:00:55Z"
id: 754306
url: "https://showcup.iteye.com/blog/754306"
---

SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance(); SOAPConnection con = factory.createConnection(); SOAPMessage request = MessageFactory.newInstance(SOAPConstants.SOAP\_1\_1\_PROTOCOL).createMessage(); request.getSOAPHeader().detachNode(); SOAPBody body = request.getSOAPBody(); SOAPElement getMessage = body.addChildElement("call", "ns1", ASIP\_NS); getMessage.setEncodingStyle(SOAPConstants.URI\_NS\_SOAP\_ENCODING); // 第一个参数 SOAPElement in0 = getMessage.addChildElement("in0"); in0.addTextNode("predeal"); // 第二个参数 SOAPElement in1 = getMessage.addChildElement("in1"); in1.addTextNode(message.getBusinessServiceParam()); //第三个参数 SOAPElement in2 = getMessage.addChildElement("in2"); in2.addTextNode("predeal"); request.writeTo(System.out); SOAPMessage response = con.call(request, "http://172.16.29.212:8000/asip/services/AsipService"); Node callResponse = response.getSOAPBody().getFirstChild(); Node callReturn = callResponse.getFirstChild(); System.out.println("\\n响应内容："+callReturn.getTextContent());