org.springframework.ws.soap.SoapHeaderElement Java Examples
The following examples show how to use
org.springframework.ws.soap.SoapHeaderElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractTraceeInterceptor.java From tracee with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected void parseContextFromSoapHeader(final WebServiceMessage message, final Channel channel) { if (message instanceof SoapMessage) { final SoapMessage soapMessage = (SoapMessage) message; final TraceeFilterConfiguration filterConfiguration = backend.getConfiguration(profile); if (filterConfiguration.shouldProcessContext(channel)) { final SoapHeader soapHeader = soapMessage.getSoapHeader(); if (soapHeader != null) { Iterator<SoapHeaderElement> tpicHeaders; try { tpicHeaders = soapHeader.examineHeaderElements(SOAP_HEADER_QNAME); } catch (SoapHeaderException ignored) { tpicHeaders = Collections.<SoapHeaderElement>emptyList().iterator(); } if (tpicHeaders.hasNext()) { final Map<String, String> parsedTpic = soapHeaderTransport.parseTpicHeader(tpicHeaders.next().getSource()); backend.putAll(filterConfiguration.filterDeniedParams(parsedTpic, channel)); } } } } else { logger.info("Message is obviously no soap message - Not instance of Spring-WS SoapMessage"); } }
Example #2
Source File: TraceeClientInterceptorTest.java From tracee with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void parseTpicHeaderFromResponseToBackend() throws Exception { final Map<String, String> context = new HashMap<>(); context.put("our key", "is our value"); final StringResult result = new StringResult(); new SoapHeaderTransport().renderSoapHeader(context, result); final Source source = new StringSource(result.toString()); final SoapHeader soapHeader = mock(SoapHeader.class); when(((SoapMessage) messageContext.getResponse()).getSoapHeader()).thenReturn(soapHeader); final SoapHeaderElement element = mock(SoapHeaderElement.class); when(element.getSource()).thenReturn(source); when(soapHeader.examineHeaderElements(eq(SOAP_HEADER_QNAME))).thenReturn(Collections.singletonList(element).iterator()); unit.handleResponse(messageContext); assertThat(backend.size(), is(1)); assertThat(backend.copyToMap(), hasEntry("our key", "is our value")); }
Example #3
Source File: TraceeClientInterceptorTest.java From tracee with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void parseTpicHeaderFromFaultResponseToBackend() throws Exception { final Map<String, String> context = new HashMap<>(); context.put("our key", "is our value"); final StringResult result = new StringResult(); new SoapHeaderTransport().renderSoapHeader(context, result); final Source source = new StringSource(result.toString()); final SoapHeader soapHeader = mock(SoapHeader.class); when(((SoapMessage) messageContext.getResponse()).getSoapHeader()).thenReturn(soapHeader); final SoapHeaderElement element = mock(SoapHeaderElement.class); when(element.getSource()).thenReturn(source); when(soapHeader.examineHeaderElements(eq(SOAP_HEADER_QNAME))).thenReturn(Collections.singletonList(element).iterator()); unit.handleFault(messageContext); assertThat(backend.size(), is(1)); assertThat(backend.copyToMap(), hasEntry("our key", "is our value")); }
Example #4
Source File: TraceeEndpointInterceptorTest.java From tracee with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void parseTpicHeaderFromRequestToTraceeBackend() throws Exception { final Map<String, String> context = new HashMap<>(); context.put("our key", "is our value"); final StringResult result = new StringResult(); new SoapHeaderTransport().renderSoapHeader(context, result); final Source source = new StringSource(result.toString()); final SoapHeader soapHeader = mock(SoapHeader.class); when(((SoapMessage) messageContext.getRequest()).getSoapHeader()).thenReturn(soapHeader); final SoapHeaderElement element = mock(SoapHeaderElement.class); when(element.getSource()).thenReturn(source); when(soapHeader.examineHeaderElements(eq(SOAP_HEADER_QNAME))).thenReturn(singletonList(element).iterator()); unit.handleRequest(messageContext, new Object()); assertThat(backend.size(), is(2)); assertThat(backend.copyToMap(), hasKey(INVOCATION_ID_KEY)); assertThat(backend.copyToMap(), hasEntry("our key", "is our value")); }
Example #5
Source File: TicketAgentEndpoint.java From spring-ws with MIT License | 5 votes |
@SuppressWarnings("unchecked") @PayloadRoot(namespace = "http://example.org/TicketAgent.xsd", localPart = "listFlightsRequest") @ResponsePayload public JAXBElement<TFlightsResponse> listFlights( @RequestPayload JAXBElement<TListFlights> request, @SoapHeader( value = "{http://example.org/TicketAgent.xsd}listFlightsSoapHeaders") SoapHeaderElement soapHeaderElement) { String clientId = "unknown"; try { // create an unmarshaller JAXBContext context = JAXBContext.newInstance(ObjectFactory.class); Unmarshaller unmarshaller = context.createUnmarshaller(); // unmarshal the header from the specified source JAXBElement<ListFlightsSoapHeaders> headers = (JAXBElement<ListFlightsSoapHeaders>) unmarshaller .unmarshal(soapHeaderElement.getSource()); // get the header values 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)); // add an extra flightNumber in the case of a clientId == abc123 if ("abc123".equals(clientId)) { LOGGER.info("clientId == abc123"); tFlightsResponse.getFlightNumber().add(BigInteger.valueOf(202)); } return factory.createListFlightsResponse(tFlightsResponse); }
Example #6
Source File: TraceeClientInterceptorTest.java From tracee with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void skipResponseHeaderProcessingIfNoTpicHeaderIsPresent() throws Exception { final SoapHeader soapHeader = mock(SoapHeader.class); when(((SoapMessage) messageContext.getResponse()).getSoapHeader()).thenReturn(soapHeader); when(soapHeader.examineHeaderElements(eq(SOAP_HEADER_QNAME))).thenReturn(Collections.<SoapHeaderElement>emptyList().iterator()); unit.handleResponse(messageContext); assertThat(backend.size(), is(0)); }
Example #7
Source File: TraceeEndpointInterceptorTest.java From tracee with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void skipIncomingHeaderProcessingIfNoTpicHeaderIsPresentAndGenerateRequestId() throws Exception { final SoapHeader soapHeader = mock(SoapHeader.class); when(((SoapMessage) messageContext.getRequest()).getSoapHeader()).thenReturn(soapHeader); when(soapHeader.examineHeaderElements(eq(SOAP_HEADER_QNAME))).thenReturn(Collections.<SoapHeaderElement>emptyList().iterator()); unit.handleRequest(messageContext, new Object()); assertThat(backend.copyToMap(), hasKey(INVOCATION_ID_KEY)); assertThat(backend.size(), is(1)); }
Example #8
Source File: PermissionCheckingEndpointInterceptor.java From openemm with GNU Affero General Public License v3.0 | 4 votes |
@Override public final boolean understands(final SoapHeaderElement header) { return true; }
Example #9
Source File: ThrottlingInterceptor.java From openemm with GNU Affero General Public License v3.0 | 4 votes |
@Override public boolean understands(SoapHeaderElement header) { return true; }