Transcode BS changing the encoding

While working with XML, XML encoding is a pretty major problem that we face. Various vanilla BS which we use working with XML fail if we don’t have right encoding of the XML.

Transcode BS is the one which can help us in this type of situation. We can use convert method of Transcode Service to convert from one type of encoding to another. But another problem that I have seen when we use this business service is

Problem:

I used Transcode Service’s “Convert” method to convert from UTF-8 to UTF-16. Even though encoding got changed but XML header

<?xml version=”1.0″ encoding=”UTF-8″ ?>

still contains old encoding type i.e UTF-8 which means that vanilla BS are still going to fail.

Solution:

There is a workaround that we can use to overcome this problem.

Use Transcode BS and then change the header manually (by manually I mean through script) to reflect correct encoding. Here is a sample code below provided to me by my friend Jeevan Singh which can help you to achieve that.

function ChangeHeader(Inputs, Outputs)
{
      var inXML = Inputs.GetProperty(“InputXML”);
      var outXML = inXML.substring(0,34) + “16” + inXML.substring(35);
      Outputs.SetProperty(“OutputXML”,outXML);
}

Hope this helps

This Post has been viewed : 8,722 Times


9 Responses to Transcode BS changing the encoding

  1. hi
    I think the XML prologue need to be changed when you want to interpret the XML, but if you want to just sent it in UTF-16…just sent it & then on the receiving side, they will decode it & then they can go ahead interpreting it.

  2. hi
    I think the XML prologue need to be changed when you want to interpret the XML, but if you want to just sent it in UTF-16…just sent it & then on the receiving side, they will decode it & then they can go ahead interpreting it.

  3. Hi,

    I do have a question regarding this BS. I am trying to use BS simulator to run this BS with ‘Convert’ method. Can I create a process property and copy and paste the xml or do I have to use a workflow with XML read from file and then call this BS.

    Basically how can I provide xml to any simulated EAI BS.

  4. Hi,

    I do have a question regarding this BS. I am trying to use BS simulator to run this BS with ‘Convert’ method. Can I create a process property and copy and paste the xml or do I have to use a workflow with XML read from file and then call this BS.

    Basically how can I provide xml to any simulated EAI BS.

  5. try{
    //Request = <?xml version=”1.0″ encoding=”UTF-16″?><SiebelMessage>….</SiebelMessage>
    var Request = Inputs.GetProperty(“Request String”);
    var subStr = Inputs.GetProperty(“SubString”);
    //AddString = <?xml version=”1.0″ encoding=”UTF-8″?>
    var AddString = Inputs.GetProperty(“AddString”);
    Request = Clib.strstr(Request, subStr);
    //Request = <SiebelMessage>….</SiebelMessage>
    Request = AddString+Request;
    //Request = <?xml version=”1.0″ encoding=”UTF-8″?><SiebelMessage>….</SiebelMessage>
    Outputs.SetProperty(“Request String”,Request);

    }
    catch(e){
    throw e;
    }
    finally{

    }

Leave a Reply

Contribute