如何从SOAP响应中检索日期和时间?

时间:2016-06-13 10:46:37

标签: java soap

我从端点获得了正确的SOAP响应,但是如何在服务被命中时从SOAP响应中获取日期和时间?

soapRequest = createSoapMessage(wsRequestString);
soapConnFactory = SOAPConnectionFactory.newInstance();
soapConnection = soapConnFactory.createConnection();
URL endPoint = new URL(URL);
soapResponse = soapConnection.call(soapRequest, endPoint);

2 个答案:

答案 0 :(得分:0)

应该通过HTTP标头完成。在Java中你可以这样。

import org.apache.http.HttpResponse;

String getURL = "your_url";
HttpGet get = new HttpGet(getURL);
HttpResponse responseGet = client.execute(get);
String DateTime = responseGet.getHeaders("Date");

您可以根据自己的要求挑选前3行。

答案 1 :(得分:0)

打印SOAP响应的日期和时间

soapRequest = createSoapMessage(wsRequestString);
soapConnFactory = SOAPConnectionFactory.newInstance();
soapConnection = soapConnFactory.createConnection();
URL endPoint = new URL(URL);
soapResponse = soapConnection.call(soapRequest, endPoint);
String[] str = soapResponse.getMimeHeaders().getHeader("Date");
System.out.println(str[0]);