none
Binary RRS feed

  • Question

  • Hi,

    I am fetching images from sql server and need to convert to string and pass to web service. I am using following code in scripting functoid to do conversion but it is not working. Need help.

            public static string Base64Decode(string GetImage)
            {
                byte[] b = Convert.FromBase64String(GetImage);
                string strImage = System.Text.ASCIIEncoding.UTF32.GetString(b);
                return strImage ;
            }


    Regards, vishal

    Wednesday, May 9, 2018 11:29 AM

Answers

All replies

  • Well, hold on.  For something like SQL to Web Service, you need to know and understand completely the encoding expectations on both sides.  "Convert to string" is the wrong way to do this unless one or both endpoints has already done it the 'wrong way' and can't change it.

    How are the images stored in the database?  Is it a SOAP service?  What encoding does it expect?

    Wednesday, May 9, 2018 11:56 AM
    Moderator
  • Related to BIzTalk in any way?

    A base64 encoded image is in fact just a string of data
    Check receivers requirements

    What error do get? How is it "not working"?

    rgds /Peter

    Wednesday, May 9, 2018 12:04 PM
  • Ideally the images are transferred using the base64 strings themselves. Why convert to a string specifically and then pass? You should also consider the possibility of having pipeline components which extract/insert images into the message at the send port level and not publish the entire image back to the message box database.

    Take a look at BizTalk : Analysis of Direct Mapping vs XDocument Pipeline vs Streaming Pipeline To Process Large Messages for SQL Bulk Insert 


    Mandar Dharmadhikari

    • Marked as answer by b vishal Thursday, May 10, 2018 8:57 AM
    Thursday, May 10, 2018 2:59 AM
    Moderator
  • base64binary is a valid datatype in XML so why change at all... it is supported in SOAP and WS. There is another data type hexBinary which is a representation of the binary data as a hex string. Use the appropriate datatype in your schema and you would not need to convert at all (well maybe to get the hex representation)..

    You may also want to have a look at https://msdn.microsoft.com/en-us/library/ms996427.aspx

    Regards.


    • Edited by Shankycheil Thursday, May 10, 2018 8:50 AM edit
    • Marked as answer by b vishal Thursday, May 10, 2018 8:57 AM
    Thursday, May 10, 2018 8:48 AM