Byte input to Webservice Task in SSIS 2012


  • Hi,

    I have just created a new project in SSIS 2012 and I am using a webservice task in a package.

    I imported the WSDL file and I have several inputs to set to use it properly.

    I put variables on the 4 first inputs that are strings with success but I have a problem with the last one.

    The last one is called xmlData and is in "byte" type and I can not set it correctly.

    In the XSD file I have this definition: <xsd:element minOccurs="0" name="xmlData" nillable="true" type="xsd:base64Binary" />

    It is supposed to contain a XML file that I have to encode in base64 and then fill the xmlData with the binary value.

    To encode my XML file to base64 I use a C# task but I do not know how to declare the value and how to set it.

    I do it this way:



                FileStream myStream = new FileStream(@"H:\myXML.XML", FileMode.Open, FileAccess.Read); 
                BinaryReader reader = new BinaryReader(myStream); 
                byte[] fichierXML = new byte[reader.BaseStream.Length]; 
                for (int i = 0; i < reader.BaseStream.Length; i++) 
                    fichierXML[i] = reader.ReadByte();
                string xmlAsString = EncodeBytesAsBase64(fichierXML);


                // Conversion de la String en byte[]
                byte[] xmlData = System.Text.Encoding.UTF8.GetBytes(xmlAsString);            

                Dts.Variables["User::monXmlData"].Value = xmlData;


    My variable User::monXmlData is an Object and there is no problem in execution.

    The C# script runs well and the webservice task too but I always get an error response for the webservice saying that my xmlData field is not correct.

    I think that my base64 encoding is correct because when I copy the result in my messagebox and paste in base64 decode on a free web decoder I get my original XML text.

    Is there someone who can help me please?

    Thursday, April 17, 2014 3:24 PM


  • Thanks to all that took some time to read me.

    I have finally found the solution.

    The Base64 encoding is not necessary. It is automatically done by the webservice when the request is sent.

    The important thing to remember is that when you have to send a "byte[]" variable, you have to use a "Object" variable as an imput for the webservice.

    • Marked as answer by rndhnqz Friday, April 18, 2014 12:58 PM
    Friday, April 18, 2014 12:56 PM