Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. base64 and UTF-8 encoding issue

base64 and UTF-8 encoding issue

Scheduled Pinned Locked Moved C#
wcfxmlsysadmindata-structureshelp
5 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    George_George
    wrote on last edited by
    #1

    Hello everyone, I am writing a simple web method which returns byte[], and the byte[] is encoded by UTF-8. I have investigated related WSDL and soap message, seems the underlying web services stack will use base64 encoding? For various reasons, I can not use or re-encode my return byte[] from UTF-8 to base64. Any ideas to modify the base64 encoding to UTF-8 encoding? Here is my related web methods, SOAP message and related type in WSDL

    Web service server side code

        \[WebMethod\]
        public byte\[\] HelloWorld2()
        {
            return utf8encodedbytes;
        }
    

    SOAP response

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    soap:Body
    <HelloWorld2Response xmlns="http://tempuri.org/">
    <HelloWorld2Result>base64Binary</HelloWorld2Result>
    </HelloWorld2Response>
    </soap:Body>
    </soap:Envelope>

    related type in WSDL

    xsd:base64Binary

    thanks in advance, George

    X 1 Reply Last reply
    0
    • G George_George

      Hello everyone, I am writing a simple web method which returns byte[], and the byte[] is encoded by UTF-8. I have investigated related WSDL and soap message, seems the underlying web services stack will use base64 encoding? For various reasons, I can not use or re-encode my return byte[] from UTF-8 to base64. Any ideas to modify the base64 encoding to UTF-8 encoding? Here is my related web methods, SOAP message and related type in WSDL

      Web service server side code

          \[WebMethod\]
          public byte\[\] HelloWorld2()
          {
              return utf8encodedbytes;
          }
      

      SOAP response

      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      soap:Body
      <HelloWorld2Response xmlns="http://tempuri.org/">
      <HelloWorld2Result>base64Binary</HelloWorld2Result>
      </HelloWorld2Response>
      </soap:Body>
      </soap:Envelope>

      related type in WSDL

      xsd:base64Binary

      thanks in advance, George

      X Offline
      X Offline
      Xmen Real
      wrote on last edited by
      #2

      Try this[^]

      TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can

      G 1 Reply Last reply
      0
      • X Xmen Real

        Try this[^]

        TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can

        G Offline
        G Offline
        George_George
        wrote on last edited by
        #3

        You misunderstand my question. Since I pass UTF-8 character in response, but in WSDL it is encoded as base64, there is runtime error which says XXX is invalid value in base64. So, my purpose is how to change the decoding scheme at client side to treat input as UTF-8 other than base64? Any ideas? regards, George

        X 1 Reply Last reply
        0
        • G George_George

          You misunderstand my question. Since I pass UTF-8 character in response, but in WSDL it is encoded as base64, there is runtime error which says XXX is invalid value in base64. So, my purpose is how to change the decoding scheme at client side to treat input as UTF-8 other than base64? Any ideas? regards, George

          X Offline
          X Offline
          Xmen Real
          wrote on last edited by
          #4

          perhaps this[^] may help...

          TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can

          G 1 Reply Last reply
          0
          • X Xmen Real

            perhaps this[^] may help...

            TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia> -------------------------------------------------------- 128 bit encrypted signature, crack if you can

            G Offline
            G Offline
            George_George
            wrote on last edited by
            #5

            Thanks Xmen! Your document is good, but not directly answers my issue. Please refer to here for my specific issue. Any ideas or comments? http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2935210[^] regards, George

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups