none
Shift-JIS Encoding with AS2/HTTP Receive RRS feed

  • Question

  • One of our trading partner is using Shift-JIS Encoding while sending us EDI messages to our BizTalk 2009 sever over AS2.

    I see that the messages are getting processed through AS2EDIReceive pipeline but in the EDI XML, Japanese characters are getting replaced with ??? characters. And the same gets uploaded to SAP.

    <N101>ST</N101><N102>??????</N102><N103>91</N103><N104>0005010903</N104></ns0:N1>

    Thinking that there could be an encoding issue at the EDI Disassembler component, I changed the pipeline to AS2Receive so that I should be able to view the Raw EDI. But, again it shows me ??? characters.

    N1*ST*????????????*91*0005018043

    Partner is claiming that they are sending the Japanese character for this field and they are using Shift-JIS encoding. Since the message is encrypted, we cannot see the message before AS2 Decoder gets executed

    I am not sure if Shift-JIS Encoding is supported with AS2 Decoder/HTTP Adapter. Any suggestions on how to make it working? 

    Atin Agarwal

    Wednesday, July 25, 2012 4:37 PM

All replies

  • Try the following to test MIME compatibility:

    1. Receive the message using pass-through pipeline and let the message suspend.
    2. Find the Message Context Properties for the HTTP Headers and save them to notepad.
    3. Save the notepad file using Save As and set the encoding to ANSI.
    4. Create a new test FILE send port with pass-through send pipeline.
    5. Add a filter to the send port of BTS.ReceivePortName = <your AS2 receive port>.
    6. Run another test and make sure a file is written to your FILE send port location.
    7. From the command prompt run copy <your notepad file> + <send port file> <new file.eml>
    8. Double-click on the <new file.eml> from explorer.
    9. This should open the file using either Outlook Express or Outlook.  If you don't have it locally, copy the file to a computer that does.
    10. Check to see if the Japanese characters are displayed.

    NOTE: Structure your original notepad file as follows (my sample)... make sure you have two sets of <CR><LF> characters after the headers:

    AS2-Version: 1.2
    Mime-Version: 1.0
    Message-ID: <SERVER_228625F9-0A38-4A5B-9E3C-C7ADC63FBD16>
    Content-Description: body
    Content-ID: {0FF9A50E-7BC1-4252-BEFF-C2C6523E4329}
    AS2-To: Partner
    Disposition-Notification-To: www.me.com
    AS2-From: Me
    EDIINT-Features: multiple-attachments
    Content-Type: text/plain

    This is a test AS2 Message.

    If that doesn't work try the following:

    Create a console application with the following code snippit to convert from Shift-JIS to UTF-8:

                StreamReader reader = new StreamReader(@"<your send port file>", Encoding.GetEncoding(932));
                string unicodeContents = reader.ReadToEnd();
                StreamWriter writer = new StreamWriter(@"your utf8 file", false, Encoding.UTF8);
                writer.Write(unicodeContents);
                writer.Flush();
                writer.Close();


    David Downing... If this answers your question, please Mark as the Answer. If this post is helpful, please vote as helpful.






    Wednesday, July 25, 2012 4:57 PM
  • Thanks for your reply David!

    The message sent by partner is encrypted so I need to use AS2Decoder at the receive pipeline. 

    I have got the file from partner through mail which they are trying to send. If I open the file in word, it asks for encoding to select and when I select shift-jis, I can see the Japanese characters.

    Now i tried more tests with this file locally without using AS2.

    1) Pass through scenario using file adapter at both receive and send - > If I open the Output file in word, I can the same Japanese characters. So file adapter preserves the Japanese characters as it is.

    2) Used CSharpHttp to post the file to HTTP Receive Location with pass through pipeline. I changed the code of CSharpHttp to convert encoding to shift-jis while posting to HTTP Receive location

    byte[] PostData = System.Text.Encoding.GetEncoding("shift-jis").GetBytes(txtPostData.Text.ToString());
    HttpWRequest.ContentLength = PostData.Length;
    Stream tempStream = HttpWRequest.GetRequestStream();

    If i open the output file in word, i see the Japanese characters has been replaced by some junk characters like '?_?E?s'.

    3) Used CSharpHttp to post the file to HTTP Receive Location with pass through pipeline. I changed the code of CSharpHttp to use ASCII encoding this time while posting to HTTP Receive location

    byte[] PostData = System.Text.Encoding.ASCII.GetBytes(txtPostData.Text.ToString());

    If i open the output file in word, i see the Japanese characters has been replaced by some junk characters like '?_???'.

    4) I then tried with UTF8 as well and I see Japanese characters but they are not the one which is in the input.

    So with HTTP Receive Adapter and a pass through scenario, the output file generated some different characters for the Japanese characters in the input file. 


    Atin Agarwal

    Wednesday, July 25, 2012 6:11 PM