JAX-WS client: maintain session/cookies across multiple services

前端 未结 2 2073
渐次进展
渐次进展 2020-12-05 16:08

I\'m using Netbeans to automatically create webservice clients based off WSDL files. This works well, except the webservices I\'m using require that I pass in a custom cooki

2条回答
  •  感情败类
    2020-12-05 16:45

    Just commenting because solution above didn't work for me. I got UnsupportedOperationException. I believe issue was caused because singletonMap doesn't allow changes. xml headers were also needed, so I set those first.

    Map> headers= CastUtils.cast((Map)port.getRequestContext().get("javax.xml.ws.http.request.headers"));
    if (headers == null) {
        headers = new HashMap>();
        port.getRequestContext().put("javax.xml.ws.http.request.headers", headers);
    }
    
    headers.put("Cookie", Collections.singletonList(cookieValue));
    ((BindingProvider)port).getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headers); 
    

提交回复
热议问题