怎么用xfire调用别人的一个webservice接口
1个回答
2015-11-21
展开全部
public
SOAPMessage createMessage(String target, String... values) {
try
{
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage msg = mf.createMessage();
SOAPPart sp = msg.getSOAPPart();
SOAPEnvelope envelope = sp.getEnvelope();
SOAPBody body = envelope.getBody();
SOAPElement node2 = body
.addChildElement(
new
QName(
"http://www.w3.org/2001/XMLSchema-instance"
,
target,
"ns1"
));
for
(
int
i =
0
; i < values.length; i++) {
String value = values[i];
node2.addChildElement(
"param"
+ i).addTextNode(value);
}
msg.writeTo(System.err);
msg.saveChanges();
return
msg;
}
catch
(Exception e) {
e.printStackTrace();
return
null
;
// 一般要进行错误处理,这里省略
}
}
SOAPMessage createMessage(String target, String... values) {
try
{
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage msg = mf.createMessage();
SOAPPart sp = msg.getSOAPPart();
SOAPEnvelope envelope = sp.getEnvelope();
SOAPBody body = envelope.getBody();
SOAPElement node2 = body
.addChildElement(
new
QName(
"http://www.w3.org/2001/XMLSchema-instance"
,
target,
"ns1"
));
for
(
int
i =
0
; i < values.length; i++) {
String value = values[i];
node2.addChildElement(
"param"
+ i).addTextNode(value);
}
msg.writeTo(System.err);
msg.saveChanges();
return
msg;
}
catch
(Exception e) {
e.printStackTrace();
return
null
;
// 一般要进行错误处理,这里省略
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询