搜索

首页  >  问答  >  正文

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!怎么解决 谢谢

ringa_leeringa_lee2805 天前1458

全部回复(0)我来回复

暂无回复
  • 取消回复