java soapaction设置,java - SOAP请求!no SOAPAction header!错误怎么解决

public SOAPMessage getMessage(String[] params) throws SOAPException, Exception {

SOAPMessage message = msgFactory.createMessage();

SOAPPart soapPart = message.getSOAPPart();

SOAPEnvelope soapEnvelope = soapPart.getEnvelope();

// SOAPHeader soapHeader = soapEnvelope.getHeader();

SOAPBody soapBody = soapEnvelope.getBody();

soapBody.addBodyElement(soapEnvelope.createName("userID")).addTextNode(params[0]);

soapBody.addBodyElement(soapEnvelope.createName("userToken")).addTextNode(params[1]);

message.saveChanges();

return message;

}

public void send(String requestUrl,SOAPMessage message) throws SOAPException, IOException {

SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();

SOAPConnection sc = scf.createConnection();

URL urlEndpoint = new URL(requestUrl);

SOAPMessage response = sc.call(message, urlEndpoint);

if (response != null) {

System.out.println("Receive SOAP message:");

response.writeTo(System.out);

} else {

System.err.println("No response received from partner!");

}

sc.close();

}

public static void main(String[] args) {

try {

String userID="12345678901234567890";

String userToken="99999999999999999900000010000001";

String []params={userID,userToken};

SoapSender sender = SoapSender.getInstance();

SOAPMessage message = sender.getMessage(params);

sender.send(HttpCode.URL_USER,message);

} catch (Exception e) {

e.printStackTrace();

}

}

错误信息

ns1:Client.NoSOAPAction

no SOAPAction header!

ctest01

如果我对SOAPMessage 进行message.writeTo(System.out);

错误信息变为

ns1:Client

No such operation 'userID'

ctest01

这个变化是为什么?还有no SOAPAction header!怎么解决 谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值