BizTalk Adapter Pack 1.0과 SAP Server 4.6c간의 RFC 통신시 XML Validation Error

최근 고객사에서 발생한 BizTalk Server 2006 R2(BizTalk Adapter 1.0)과 SAP Server (4.6c) 간의 RFC통신(Inbound) 시에 Table 형 자료의 필드 값이 한글이 지정되는 경우 이상한 Garbage 문자들이 끼여들어서 오류가 발생하는 문제가 접수 되었습니다.

 

문제가 발생하는 시점에 보면 아래와 같은 오류 메시지가 이벤트에 기록이 되면 Orchestration으로의 자료 전달시 오류가 발생합니다.

 

3/19/2009         오후 2:27:10      1        1        5815     BizTalk Server 2006        N/A      HCIFWEB1
A response message sent to adapter "WCF-Custom" on receive port "ReceivePort_From_SAP_RFC" with URI "sap://Client=XXX;lang=EN;@A/SOME_IP_ADDR/12?ListenerGwHost=SOME_IP_ADDR&ListenerGwServ=SAP_GW_SRV&ListenerProgramId=SAP_BIZTALK" is suspended.

     Error details: System.Xml.XmlException: '.', 16진수 값 0x00은(는) 잘못된 문자입니다. 줄 1, 위치 377

     위치: Microsoft.BizTalk.Component.XmlAsmStreamWrapper.Read(Byte[] buffer, Int32 offset, Int32 count)

     위치: System.Xml.XmlTextReaderImpl.InitStreamInput(Uri baseUri, String baseUriStr, Stream stream, Byte[] bytes, Int32 byteCount, Encoding encoding)

     위치: System.Xml.XmlTextReaderImpl..ctor(Stream stream, Byte[] bytes, Int32 byteCount, XmlReaderSettings settings, Uri baseUri, String baseUriStr, XmlParserContext context, Boolean closeInput)

     위치: System.Xml.XmlReader.CreateReaderImpl(Stream input, XmlReaderSettings settings, Uri baseUri, String baseUriStr, XmlParserContext inputContext, Boolean closeInput)

     위치: System.Xml.XmlReader.Create(Stream input, XmlReaderSettings settings, String baseUri)

     위치: System.Xml.XmlReader.Create(Stream input, XmlReaderSettings settings)

     위치: Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkBodyWriter.WriteBizTalkBody(XmlDictionaryWriter writer)

     위치: Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)

     위치: System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer)

     위치: System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer)

     위치: System.ServiceModel.Channels.Message.OnGetReaderAtBodyContents()

     위치: System.ServiceModel.Channels.Message.GetReaderAtBodyContents()

     위치: Microsoft.Adapters.SAP.SAPInboundCountractReply.AdapterReply(Message message, TimeSpan timeout)

     위치: Microsoft.Adapters.AdapterUtilities.AdapterInboundReply.Reply(Message message, TimeSpan timeout)

     위치: Microsoft.ServiceModel.Channels.Common.Channels.AdapterRequestContext.Reply(Message message, TimeSpan timeout)

     위치: Microsoft.ServiceModel.Channels.Common.Channels.AdapterRequestContext.Reply(Message message)

     위치: System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc& rpc)     MessageId:  {xxxxxxxxx}    InstanceID: {YYYYYYYYYY}

 

문제는 자료를 아래와 같이 필드의 길이에 맞는 ASCII 문자만을 보낼 경우는 문제가 없었습니다. (아래의 Schema는 원래 자료의 내용을 바탕으로 재구성하였으며 SAP 서버에서 실제 생성된 것은 아닙니다.)

 

<?xml version="1.0" encoding="utf-8"?>
<SAP_Data_Root xmlns="https://Microsoft.LobServices.Sap/2007/03/Rfc/">
  <TableDataElement>
    <TableData01 xmlns="https://Microsoft.LobServices.Sap/2007/03/Types/Rfc/">
      <ProductCode>A100</ProductCode>
      <StandardCode>111</StandardCode>
      <TransitionType>2</TransitionType>
      <ProductName>333</ProductName>
      <RealNAME></RealNAME>
      <ShippingDate></ShippingDate>
    </TableData01>
  </TableDataElement>
</SAP_Data_Root>

 

한글을 포함한 자료를 SAP에서 보내게 되면 아래와 같이 공백과 함께 NULL Entity(&#x0;) 가 Field의 길이에 맞게 Padding 되는 듯하면서 추가되고 있는 것을 볼 수 있습니다. 이들 문자에 의해서 XML Validation이 실패하면서 Request를 정상처리하지 못하고 있었습니다.

<?xml version="1.0" encoding="utf-8"?>
<SAP_Data_Root xmlns="https://Microsoft.LobServices.Sap/2007/03/Rfc/">
  <TableDataElement>
    <TableData01 xmlns="https://Microsoft.LobServices.Sap/2007/03/Types/Rfc/">
      <ProductCode>A100</ProductCode>
      <StandardCode>111</StandardCode>
      <TransitionType>1</TransitionType>
      <ProductName>한글 한글 한글                                                        &#x0;&#x0;&#x0;&#x0;&#x0;&#x0;</ProductName>
      <RealNAME>한글 2 한                     &#x0;&#x0;&#x0;</RealNAME>
      <ShippingDate></ShippingDate>
    </TableData01>
  </TableDataElement>
</SAP_Data_Root>

 

관련 문제는 SAP RFC SDK 7.1 UNICODE 를 SAP RFC SDK 7.0 UNICODE로 downgrade 하면서 해결 되었습니다. 아마도 SAP RFC SDK 7.1 UNICODE 버젼에 MBCS 스트링 자료 처리에 문제가 있었을 것으로 보입니다만 정확한 원인 확인은 좀 더 시간일 걸릴 것으로 보입니다.

 

SAP RFC SDK를 다운로드 하는 방법은 아래의 Blog 글을 참고하세요. 물론 SAP쪽의 지원 계약이 있으셔야 다운로드가 가능합니다.

https://blogs.msdn.com/adapters/archive/2007/10/07/obtaining-the-rfc-sdk-unicode-libraries-from-sap-service-marketplace.aspx

 

BizTalk Server 설치 이후에 SAP의 TABLE Type이 지원되는 않을 경우, 아래의 KB에서 언급하는 Hotfix를 설치해야 할 수 있습니다.

 

FIX: The Windows Communication Foundation (WCF) based SAP adapter from BizTalk Server 2006 Adapter Pack v1.0 does not support the SAP TABLE type

https://support.microsoft.com/kb/956635