use of org.springframework.ws.soap.SoapHeaderElement in project camel by apache.
the class SpringWebserviceConsumer method extractSourceFromSoapHeader.
/**
* Extracts the SOAP headers and set them as headers in the Exchange. Also sets
* it as a header with the key SpringWebserviceConstants.SPRING_WS_SOAP_HEADER
* and a value of type Source.
*
* @param headers the Exchange Headers
* @param request the WebService Request
*/
private void extractSourceFromSoapHeader(Map<String, Object> headers, WebServiceMessage request) {
if (request instanceof SoapMessage) {
SoapMessage soapMessage = (SoapMessage) request;
SoapHeader soapHeader = soapMessage.getSoapHeader();
if (soapHeader != null) {
//Set the raw soap header as a header in the exchange.
headers.put(SpringWebserviceConstants.SPRING_WS_SOAP_HEADER, soapHeader.getSource());
//Set header values for the soap header attributes
Iterator<QName> attIter = soapHeader.getAllAttributes();
while (attIter.hasNext()) {
QName name = attIter.next();
headers.put(name.getLocalPart(), soapHeader.getAttributeValue(name));
}
//Set header values for the soap header elements
Iterator<SoapHeaderElement> elementIter = soapHeader.examineAllHeaderElements();
while (elementIter.hasNext()) {
SoapHeaderElement element = elementIter.next();
QName name = element.getName();
headers.put(name.getLocalPart(), element);
}
}
}
}
use of org.springframework.ws.soap.SoapHeaderElement in project camel by apache.
the class SpringWebserviceProducer method populateMessageHeaderFromResponse.
/**
* Populates message headers from soapHeader response
*
* @param message
* Message
* @param soapHeader
* SoapHeader
*/
private void populateMessageHeaderFromResponse(Message message, SoapHeader soapHeader) {
message.setHeader(SpringWebserviceConstants.SPRING_WS_SOAP_HEADER, soapHeader.getSource());
// Set header values for the soap header attributes
Iterator<QName> attIter = soapHeader.getAllAttributes();
while (attIter.hasNext()) {
QName name = attIter.next();
message.getHeaders().put(name.getLocalPart(), soapHeader.getAttributeValue(name));
}
// Set header values for the soap header elements
Iterator<SoapHeaderElement> elementIter = soapHeader.examineAllHeaderElements();
while (elementIter.hasNext()) {
SoapHeaderElement element = elementIter.next();
QName name = element.getName();
message.getHeaders().put(name.getLocalPart(), element);
}
}
use of org.springframework.ws.soap.SoapHeaderElement in project webservices-axiom by apache.
the class AxiomSoapMessageTest method testSetDocument.
/**
* Tests that {@link AxiomSoapMessage#setDocument(Document)} works correctly. There have been
* issues with that method because Spring-WS instantiates {@link SOAPFactory} implementations
* directly instead of using {@link OMAbstractFactory}.
*
* @throws Exception
*/
public void testSetDocument() throws Exception {
AxiomSoapMessageFactory mf = new AxiomSoapMessageFactory();
mf.afterPropertiesSet();
AxiomSoapMessage message = mf.createWebServiceMessage();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
Document document = dbf.newDocumentBuilder().parse(AxiomSoapMessageTest.class.getResource("soap-message.xml").toString());
message.setDocument(document);
Iterator<SoapHeaderElement> it = message.getEnvelope().getHeader().examineAllHeaderElements();
assertTrue(it.hasNext());
SoapHeaderElement headerElement = it.next();
assertEquals(new QName("urn:test", "myHeader"), headerElement.getName());
}
Aggregations