2

I'm using Spring-WS to build a web service (contract first). I defined an endpoint like below

@Endpoint
public class ReportingEndpoint {
    private static final Logger LOGGER = LoggerFactory.getLogger(ReportingEndpoint.class);

    private static final String NAMESPACE_URI = "http://localhost/reporting";

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "RequestDocument")
    @ResponsePayload
    public ResponseDocument accountReporting(
            @RequestPayload JAXBElement<RequestDocument> request,
            @SoapHeader(value = "{http://localhost/reporting}Hdr") SoapHeaderElement header) {
        try {
            ApplicationHeader headers = ((JAXBElement<ApplicationHeader>) JAXBUtils
                    .unmarshal(header.getSource(), ObjectFactory.class)).getValue();
            LOGGER.info(headers.getSystemName());
            LOGGER.info("Hello world.");

            ResponseDocument response = new ResponseDocument();
            response.setReportTitle("Report Title");
            return response;
        } catch (Exception ex) {
            return null;
        }
    }
}

This code can receive and read the soap header sent from client but when I return a response message, I don't know how to send back to client the server soap header as the client did. Can anybody help me to solve this issue?

anhtuangv
  • 545
  • 6
  • 11
  • I found the solution here https://stackoverflow.com/questions/8521104/how-to-read-soap-header-information-from-request-and-add-it-to-response-in-sprin – anhtuangv Nov 10 '17 at 08:00

0 Answers0