17.12. VMDK 모드에서 iPXE 헤더를 가져오고 설정하는 방법


CloudEvent 는 camel-cxf 엔드포인트에서 Camel exchange를 생성하거나 사용할 때 데이터 형식이 "Java 개체 목록"임을 나타냅니다. Camel이 이 모드에서 메시지 본문을 10.0.0.1s로 노출하지만 camel-cxf는 여전히 읽기 및 쓰기 headers에 대한 액세스를 제공합니다. 그러나 CXF 인터셉터가 처리된 후 헤더 목록에서 대역 내 CHAP 헤더를 제거하므로 대역 외 iPXE 헤더만 generated 모드에서 camel-cxf를 사용할 수 있습니다.

다음 예제에서는 CHAP 헤더를 가져오고 설정하는 방법을 보여줍니다. 하나의 Camel-cxf 끝점에서 다른 endpoint로 전달되는 경로가 있다고 가정합니다. 즉, iPXE 클라이언트 Camel CXF 서비스입니다. 요청이 CXF 서비스에 나가기 전에 (1)에서 두 개의 프로세서를 첨부할 수 있습니다. (2) 응답이 iPXE Client로 반환되기 전에 이 예에서 processor (1) 및 (2)는 InsertRequestOutHeaderProcessor 및 InsertResponseOutHeaderProcessor입니다. 이 경로는 다음과 같습니다.

from("cxf:bean:routerRelayEndpointWithInsertion")
    .process(new InsertRequestOutHeaderProcessor())
    .to("cxf:bean:serviceRelayEndpointWithInsertion")
    .process(new InsertResponseOutHeaderProcessor());

iPXE routerRelayEndpointWithInsertionserviceRelayEndpointWithInsertion 은 다음과 같이 정의됩니다.

@Bean
public CxfEndpoint routerRelayEndpointWithInsertion() {
    CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
    cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.soap.headers.HeaderTester.class);
    cxfEndpoint.setAddress("/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpointWithInsertion");
    cxfEndpoint.setWsdlURL("soap_header.wsdl");
    cxfEndpoint.setEndpointNameAsQName(
        QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SoapPortRelayWithInsertion"));
    cxfEndpoint.setServiceNameAsQName(SERVICENAME);
    cxfEndpoint.getFeatures().add(new LoggingFeature());
    return cxfEndpoint;
}

@Bean
public CxfEndpoint serviceRelayEndpointWithInsertion() {
    CxfSpringEndpoint cxfEndpoint = new CxfSpringEndpoint();
    cxfEndpoint.setServiceClass(org.apache.camel.component.cxf.soap.headers.HeaderTester.class);
    cxfEndpoint.setAddress("http://localhost:" + port + "/services/CxfMessageHeadersRelayTest/HeaderService/routerRelayEndpointWithInsertionBackend");
    cxfEndpoint.setWsdlURL("soap_header.wsdl");
    cxfEndpoint.setEndpointNameAsQName(
        QName.valueOf("{http://apache.org/camel/component/cxf/soap/headers}SoapPortRelayWithInsertion"));
    cxfEndpoint.setServiceNameAsQName(SERVICENAME);
    cxfEndpoint.getFeatures().add(new LoggingFeature());
    return cxfEndpoint;
}

CloudEvent 헤더는 Camel Message 헤더로 또는 에서 전파됩니다. Camel 메시지 헤더 이름은 CXF(org.apache.cxf.headers.Header.HEADER_LIST)에 정의된 상수인 "org.apache.cxf.headers.Header.list"입니다. 헤더 값은 CXF SoapHeader 오브젝트 목록(org.apache.cxf.binding.soap.SoapHeader)입니다. 다음 스니펫은 InsertResponseOutHeaderProcessor(응답 메시지에 새 iPXE 헤더를 삽입함)입니다. InsertResponseOutHeaderProcessor 및 InsertRequestOutHeaderProcessor 모두에서 iPXE 헤더에 액세스하는 방법은 실제로 동일합니다. 두 프로세서의 유일한 차이점은 삽입된 CHAP 헤더의 방향을 설정하는 것입니다.

CxfMessageHeadersRelayTest 에서 InsertResponseOutHeaderProcessor 예제를 찾을 수 있습니다.

public static class InsertResponseOutHeaderProcessor implements Processor {

    public void process(Exchange exchange) throws Exception {
        List<SoapHeader> soapHeaders = CastUtils.cast((List<?>)exchange.getIn().getHeader(Header.HEADER_LIST));

        // Insert a new header
        String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><outofbandHeader "
            + "xmlns=\"http://cxf.apache.org/outofband/Header\" hdrAttribute=\"testHdrAttribute\" "
            + "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" soap:mustUnderstand=\"1\">"
            + "<name>New_testOobHeader</name><value>New_testOobHeaderValue</value></outofbandHeader>";
        SoapHeader newHeader = new SoapHeader(soapHeaders.get(0).getName(),
                       DOMUtils.readXml(new StringReader(xml)).getDocumentElement());
        // make sure direction is OUT since it is a response message.
        newHeader.setDirection(Direction.DIRECTION_OUT);
        //newHeader.setMustUnderstand(false);
        soapHeaders.add(newHeader);

    }

}
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

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

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

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

Red Hat 소개

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

Theme

© 2026 Red Hat
맨 위로 이동