如何在客户端使用 jaxws 访问网络服务响应 header?
How can I get access to the websevice response header using jaxws on the client side?
我正在开发一个应用程序,当我使用 jaxws wsimport 导入 wsdl web 服务时,这抽象了 Java 类 的复杂类型。但它抽象为 类 只是 body 响应,我需要在网络服务响应 header 中获取一些数据,如何使用 jaxws 访问网络服务响应 header在客户端?
代码:
//Instance of Service
SessionCreateRQService sessionCreateService = new SessionCreateRQService();
SessionCreatePortType requestSessionCreate = sessionCreateService.getSessionCreatePortType();
//Get datas to request header
MessageHeader messageHeader = getMessageHeader(MESSAGE_ID, timestamp, URI_PartyId, Services.SessionCreateRQ ,Actions.SessionCreateRQ);
Holder<MessageHeader> holderMessage = new Holder<MessageHeader>(messageHeader);
//Get another datas to request header
Security security = getSecuritySessionCreateRQ();
Holder<Security> holderSecurity = new Holder<>(security);
//Get datas to quest body
SessionCreateRQ body = new SessionCreateRQ();
body.setPOS(getPOS());
//Call the websevice and receiving the response.
// ---->>>I need access the response webservice header here.<<-----
SessionCreateRS sessionCreateRS = requestSessionCreate.sessionCreateRQ(holderMessage, holderSecurity, body);
谢谢。
您需要在客户端中添加处理程序才能这样做
您可以找到更多详细信息here
我正在开发一个应用程序,当我使用 jaxws wsimport 导入 wsdl web 服务时,这抽象了 Java 类 的复杂类型。但它抽象为 类 只是 body 响应,我需要在网络服务响应 header 中获取一些数据,如何使用 jaxws 访问网络服务响应 header在客户端?
代码:
//Instance of Service
SessionCreateRQService sessionCreateService = new SessionCreateRQService();
SessionCreatePortType requestSessionCreate = sessionCreateService.getSessionCreatePortType();
//Get datas to request header
MessageHeader messageHeader = getMessageHeader(MESSAGE_ID, timestamp, URI_PartyId, Services.SessionCreateRQ ,Actions.SessionCreateRQ);
Holder<MessageHeader> holderMessage = new Holder<MessageHeader>(messageHeader);
//Get another datas to request header
Security security = getSecuritySessionCreateRQ();
Holder<Security> holderSecurity = new Holder<>(security);
//Get datas to quest body
SessionCreateRQ body = new SessionCreateRQ();
body.setPOS(getPOS());
//Call the websevice and receiving the response.
// ---->>>I need access the response webservice header here.<<-----
SessionCreateRS sessionCreateRS = requestSessionCreate.sessionCreateRQ(holderMessage, holderSecurity, body);
谢谢。
您需要在客户端中添加处理程序才能这样做
您可以找到更多详细信息here