如何在客户端使用jaxws访问websevice响应标头?

时间:2018-07-13 13:40:26

标签: java soap jax-ws webservice-client wsimport

我正在开发一个应用程序,当我用jaxws wsimport导入wsdl Web服务时,这抽象了Java类的复杂类型。但是它抽象为仅是主体响应的类,并且我需要在Web服务响应标头中获取一些数据,如何在客户端使用jaxws访问Web服务响应标头?

代码:

    //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);

谢谢。

1 个答案:

答案 0 :(得分:0)

您需要在客户端中添加一个处理程序,

您可以找到更多详细信息here