Java 类org.apache.camel.component.spring.ws.SpringWebserviceConstants 实例源码

项目:Camel    文件:PrecedenceProcessor.java   
public void process(Exchange exchange) throws Exception {
    // same sample data
    InputStream is = getClass().getResourceAsStream("/stockquote-response.xml");
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(is);

    exchange.getIn().setHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION, new URI("http://actionPrecedence.com"));
    exchange.getIn().setHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_REPLY_TO, new URI("http://replyPrecedence.to"));
    exchange.getIn().setHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_FAULT_TO, new URI("http://faultPrecedence.to"));

    exchange.getIn().setHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_CONSUMER_OUTPUT_ACTION, new URI("http://outputHeader.com"));
    exchange.getIn().setHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_CONSUMER_FAULT_ACTION, new URI("http://faultHeader.com"));

    exchange.getOut().copyFrom(exchange.getIn());
    exchange.getOut().setBody(doc);
}
项目:Camel    文件:BasicMessageFilterTest.java   
@Test
public void removeCamelInternalHeaderAttributes() throws Exception {
    exchange.getOut().getHeaders().put(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION, "mustBeRemoved");
    exchange.getOut().getHeaders().put(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION, "mustBeRemoved");
    exchange.getOut().getHeaders().put(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_FAULT_TO, "mustBeRemoved");
    exchange.getOut().getHeaders().put(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_REPLY_TO, "mustBeRemoved");
    exchange.getOut().getHeaders().put(SpringWebserviceConstants.SPRING_WS_ADDRESSING_CONSUMER_FAULT_ACTION, "mustBeRemoved");
    exchange.getOut().getHeaders().put(SpringWebserviceConstants.SPRING_WS_ADDRESSING_CONSUMER_OUTPUT_ACTION, "mustBeRemoved");
    exchange.getOut().getHeaders().put(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI, "mustBeRemoved");

    exchange.getOut().getHeaders().put("BreadcrumbId", "mustBeRemoved");

    filter.filterConsumer(exchange, message);

    Assertions.assertThat(message.getAttachments()).isEmpty();
    Assertions.assertThat(message.getSoapHeader().examineAllHeaderElements()).isEmpty();

    Assertions.assertThat(message.getSoapHeader().getAllAttributes()).isEmpty();
}
项目:Camel    文件:BasicMessageFilter.java   
/**
 * The SOAP header is populated from exchange.getOut().getHeaders() if this
 * class is used by the consumer or exchange.getIn().getHeaders() if this
 * class is used by the producer. If .getHeaders() contains under a certain
 * key a value with the QName object, it is directly added as a new header
 * element. If it contains only a String value, it is transformed into a
 * header attribute. Following headers are excluded:
 */
protected void doProcessSoapHeader(Message inOrOut, SoapMessage soapMessage) {
    SoapHeader soapHeader = soapMessage.getSoapHeader();

    Map<String, Object> headers = inOrOut.getHeaders();

    HashSet<String> headerKeySet = new HashSet<String>(headers.keySet());

    headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION);
    headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI);
    headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION);
    headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_FAULT_TO);
    headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_REPLY_TO);
    headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_CONSUMER_FAULT_ACTION);
    headerKeySet.remove(SpringWebserviceConstants.SPRING_WS_ADDRESSING_CONSUMER_OUTPUT_ACTION);

    headerKeySet.remove(BREADCRUMB_ID);

    for (String name : headerKeySet) {
        Object value = headers.get(name);

        if (value instanceof QName) {
            soapHeader.addHeaderElement((QName)value);
        } else {
            if (value instanceof String) {
                soapHeader.addAttribute(new QName(name), value + "");
            }
        }
    }
}
项目:cleverbus    文件:DirectCallWsRoute.java   
/**
 * Sets request header if available.
 *
 * @param callId Call ID for getting call parameters from {@link DirectCallRegistry}
 * @param exchange Camel exchange
 */
@Handler
public void setHeader(@Header(CALL_ID_HEADER) String callId, Exchange exchange) {
    Assert.hasText(callId, "the callId must not be empty");

    DirectCallParams params = callRegistry.getParams(callId);

    if (params.getHeader() != null) {
        Log.debug("Direct WS call: header=" + params.getHeader());

        exchange.getIn().setHeader(SpringWebserviceConstants.SPRING_WS_SOAP_HEADER, params.getHeader());
    }
}
项目:wildfly-camel    文件:SpringWsIntegrationTest.java   
@Test
public void consumeStockQuoteWebserviceAndProvideEndpointUriByHeader() throws Exception {
    Object result = template.requestBodyAndHeader("direct:stockQuoteWebserviceWithoutDefaultUri", xmlRequestForGoogleStockQuote,
            SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI, stockQuoteWebserviceUri);

    Assert.assertNotNull(result);
    Assert.assertTrue(result instanceof String);
    String resultMessage = (String) result;
    Assert.assertTrue(resultMessage.contains("Google Inc."));
}