简体   繁体   中英

Date in header of soap response

Am writing a CXF based web service. I need to pass date in response header as local server time , but this is getting returned as GMT, as show below

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)/Tomcat-5.5
Date: Mon, 28 Aug 2017 06:47:51 GMT
Content-Type: text/xml;charset=UTF-8
Content-Length: 436

But if i set a value Date1 as header

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)/Tomcat-5.5
Date1: Mon Aug 28 12:38:47 IST 2017
Content-Type: text/xml;charset=UTF-8
Content-Length: 436
Date: Mon, 28 Aug 2017 07:08:47 GMT

Can't we able to override Date here ,if yes can some one help me out from this?

If you want to edit http headers before message is sent, then you can create interceptor, add it to outgoing interceptors and do it there.

public class HttpHeaderInterceptor extends AbstractPhaseInterceptor<Message>{

public HttpHeaderInterceptor() {
 super(Phase.POST_LOGICAL);
 }

public void handleMessage(Message message) {
 Map<String, List<String>> headers = new HashMap<String, List<String>>();
 headers.put("xxx", "yyyy");
 message.put(Message.PROTOCOL_HEADERS, headers);
 }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM