TicketAgentEndpoint { @SuppressWarnings("unchecked") @PayloadRoot(namespace = "http: @ResponsePayload public JAXBElement<TFlightsResponse> listFlights( @RequestPayload JAXBElement<TListFlights> request, @SoapHeader( value = "{http: String clientId = "unknown"; try { JAXBContext context = JAXBContext.newInstance(ObjectFactory.class); Unmarshaller unmarshaller = context.createUnmarshaller(); JAXBElement<ListFlightsSoapHeaders> headers = (JAXBElement<ListFlightsSoapHeaders>) unmarshaller .unmarshal(soapHeaderElement.getSource()); ListFlightsSoapHeaders requestSoapHeaders = headers.getValue(); clientId = requestSoapHeaders.getClientId(); } catch (Exception e) { LOGGER.error("error during unmarshalling of the SOAP headers", e); } ObjectFactory factory = new ObjectFactory(); TFlightsResponse tFlightsResponse = factory.createTFlightsResponse(); tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(101)); if ("abc123".equals(clientId)) { LOGGER.info("clientId == abc123"); tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(202)); } return factory.createListFlightsResponse(tFlightsResponse); }  @SuppressWarnings("unchecked") @PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest") @ResponsePayload JAXBElement<TFlightsResponse> listFlights(
      @RequestPayload JAXBElement<TListFlights> request, @SoapHeader(
          value = "{http://example.org/TicketAgent.xsd}listFlightsSoapHeaders") SoapHeaderElement soapHeaderElement);  }
@Test public void testListFlights() { Source requestEnvelope = new StringSource( "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http: + "<SOAP-ENV:Header>" + "<ns3:listFlightsSoapHeaders xmlns:ns3=\"http: + "<isGoldClubMember>true</isGoldClubMember>" + "<clientId>abc123</clientId>" + "</ns3:listFlightsSoapHeaders>" + "</SOAP-ENV:Header>" + "<SOAP-ENV:Body>" + "<ns3:listFlightsRequest xmlns:ns3=\"http: + "</ns3:listFlightsRequest>" + "</SOAP-ENV:Body>" + "</SOAP-ENV:Envelope>"); Source responsePayload = new StringSource("<v1:listFlightsResponse xmlns:v1=\"http: + "<flightNumber>101</flightNumber>" + "<flightNumber>202</flightNumber>" + "</v1:listFlightsResponse>"); mockClient.sendRequest(withSoapEnvelope(requestEnvelope)).andExpect(payload(responsePayload)); }