289.13. IDoc용 XML 직렬화

289.13.1. 개요

IDoc 메시지 본문을 기본 제공 형식 변환기를 사용하여 XML 문자열 형식으로 직렬화할 수 있습니다.

289.13.2. XML 네임 스페이스

각 직렬화된 IDoc은 다음과 같은 일반 형식이 있는 XML 네임스페이스와 연결됩니다.

http://sap.fusesource.org/idoc/repositoryName/idocType/idocTypeExtension/systemRelease/applicationRelease

repositoryName (원격 SAP 메타데이터 리포지토리의 이름)과 idocType (IDoc 문서 유형)이 모두 필수이지만 네임스페이스의 다른 구성 요소는 비워 둘 수 있습니다. 예를 들어 다음과 같은 XML 네임스페이스가 있을 수 있습니다.

http://sap.fusesource.org/idoc/MY_REPO/FLCUSTOMER_CREATEFROMDATA01///

289.13.3. 기본 제공 유형 변환기

Camel SAP 구성 요소에는 Document 개체 또는 DocumentList 오브젝트를 String 유형으로 변환할 수 있는 기본 제공 유형 변환기가 있습니다.

예를 들어 Document 개체를 XML 문자열로 직렬화하려면 XML DSL의 경로에 다음 행을 간단히 추가할 수 있습니다.

<convertBodyTo type="java.lang.String"/>

이 방법을 사용하여 Document 개체에 직렬화된 XML 메시지를 사용할 수도 있습니다. 예를 들어 현재 메시지 본문이 직렬화된 XML 문자열인 경우 XML DSL의 경로에 다음 줄을 추가하여 Document 개체로 변환할 수 있습니다.

<convertBodyTo type="org.fusesource.camel.component.sap.model.idoc.Document"/>

289.13.4. XML 형식의 IDoc 메시지 본문 샘플

IDoc 메시지를 String 으로 변환할 때 XML 문서로 직렬화됩니다. 여기서 루트 요소는 idoc:Document (단일 문서의 경우) 또는 idoc:DocumentList (문서 목록)입니다. 예 289.2. “XML의 IDoc 메시지 DestinationRule” idoc:Document 요소로 직렬화된 단일 IDoc 문서를 표시합니다.

예 289.2. XML의 IDoc 메시지 DestinationRule

<?xml version="1.0" encoding="ASCII"?>
<idoc:Document
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:FLCUSTOMER_CREATEFROMDATA01---="http://sap.fusesource.org/idoc/XXX/FLCUSTOMER_CREATEFROMDATA01///"
    xmlns:idoc="http://sap.fusesource.org/idoc"
    creationDate="2015-01-28T12:39:13.980-0500"
    creationTime="2015-01-28T12:39:13.980-0500"
    iDocType="FLCUSTOMER_CREATEFROMDATA01"
    iDocTypeExtension=""
    messageType="FLCUSTOMER_CREATEFROMDATA"
    recipientPartnerNumber="QUICKCLNT"
    recipientPartnerType="LS"
    senderPartnerNumber="QUICKSTART"
    senderPartnerType="LS">
  <rootSegment xsi:type="FLCUSTOMER_CREATEFROMDATA01---:ROOT" document="/">
    <segmentChildren parent="//@rootSegment">
      <E1SCU_CRE parent="//@rootSegment" document="/">
        <segmentChildren parent="//@rootSegment/@segmentChildren/@E1SCU_CRE.0">
          <E1BPSCUNEW parent="//@rootSegment/@segmentChildren/@E1SCU_CRE.0"
              document="/"
              CUSTNAME="Fred Flintstone" FORM="Mr."
              STREET="123 Rubble Lane"
              POSTCODE="01234"
              CITY="Bedrock"
              COUNTR="US"
              PHONE="800-555-1212"
              EMAIL="fred@bedrock.com"
              CUSTTYPE="P"
              DISCOUNT="005"
              LANGU="E"/>
        </segmentChildren>
      </E1SCU_CRE>
    </segmentChildren>
  </rootSegment>
</idoc:Document>