16.10. how to prepare the message for the camel-cxf endpoint in#177 data format


camel-cxf 끝점 프로듀서는 CXF 클라이언트 API 를 기반으로 합니다. 먼저 메시지 헤더에 작업 이름을 지정한 다음 메서드 매개변수를 목록에 추가하고 이 매개변수 목록으로 메시지를 초기화해야 합니다. 응답 메시지의 본문은 messageContentsList이며 해당 목록의 결과를 가져올 수 있습니다.

메시지 헤더에 작업 이름을 지정하지 않으면 CxfProducerCxfEndpoint기본OperationName 을 사용하려고 합니다. CxfEndpoint기본OperationName 이 설정되지 않은 경우 Operation 목록에서 첫 번째 operationName을 선택합니다.

메시지 본문에서 개체 배열을 가져오려면 CxfProducerRouterTest.testInvokingSimpleServerWithParams 와 같이 message.getBody(Object[].class) 를 사용하여 본문을 가져올 수 있습니다.

Exchange senderExchange = new DefaultExchange(context, ExchangePattern.InOut);
final List<String> params = new ArrayList<>();
// Prepare the request message for the camel-cxf procedure
params.add(TEST_MESSAGE);
senderExchange.getIn().setBody(params);
senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, ECHO_OPERATION);

Exchange exchange = template.send("direct:EndpointA", senderExchange);

org.apache.camel.Message out = exchange.getMessage();
// The response message's body is an MessageContentsList which first element is the return value of the operation,
// If there are some holder parameters, the holder parameter will be filled in the reset of List.
// The result will be extract from the MessageContentsList with the String class type
MessageContentsList result = (MessageContentsList) out.getBody();
LOG.info("Received output text: " + result.get(0));
Map<String, Object> responseContext = CastUtils.cast((Map<?, ?>) out.getHeader(Client.RESPONSE_CONTEXT));
assertNotNull(responseContext);
assertEquals("UTF-8", responseContext.get(org.apache.cxf.message.Message.ENCODING),
        "We should get the response context here");
assertEquals("echo " + TEST_MESSAGE, result.get(0), "Reply body on Camel is wrong");
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동