0

Am trying to send a soap request using jax-ws-spring framework, but there was a change request to send credentials in soap header. i have tried to implement a method where it sets the username and password in soap header, however i don't see the header displaying in the request when i monitor from TCP/IP monitor from eclipse.

@PostConstruct
    public void initialize(){
            try {
                CaseRequestService caseRequestService = new CaseRequestService();
                CaseRequestPortType caseRequestPort = caseRequestService.getCaseRequestPort();
                BindingProvider bindingProvider = (BindingProvider) caseRequestPort;
                Log.info("wsAddress"+wsAddress);
                //bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsAddress);
                Map<String, Object> requestContext =   ((BindingProvider)bindingProvider).getRequestContext();
                Map<String, String> requestHeaders = new HashMap<String, String>();
                requestHeaders.put("username", loadConfig.getSoap_header_uid());
                requestHeaders.put("Password", Base64.getDecoder().decode(loadConfig.getSoap_header_pwd().getBytes()).toString());
                requestContext.put(MessageContext.HTTP_REQUEST_HEADERS, requestHeaders);
            } catch (Exception ex) {
                log.error("Error in initializing CaseRequestService: ", ex);
            }
        }
  • Your code is setting an HTTP header, not a SOAP header. (And you're basically ignoring all errors; remove the try/catch block.) – David Maze Oct 19 '18 at 18:11
  • thanks,i figured out it .. between if i remove try/catch i will not be able to cat the exception right ? – Kumar Prasad Oct 24 '18 at 07:10

0 Answers0