Android calls. Net WebService to pass byte []

Source: Internet
Author: User

Android calls. Net WebService to pass byte []

 

Android code:

SoapObject request = new SoapObject (Constant. NAMESPACE, "XXXX"); <br/> // request. addProperty ("strIn", "123456"); <br/> byte [] byValue; <br/> byValue = "Hello world ". getBytes (); <br/> String strByte = Base64.encode (byValue); <br/> request. addProperty ("condtion", strByte); </p> <p> SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (<br/> SoapEnvelope. VER11); <br/> envelope. dotNet = true; <br/> envelope. setOutputSoapObject (request); <br/> new MarshalBase64 (). register (envelope); </p> <p> // send a request <br/> AndroidHttpTransport aht = new AndroidHttpTransport (Constant. URL); <br/> // aht. debug = true; </p> <p> try {<br/> aht. call (Constant. SOAP_ACTION + "XXXX", envelope); <br/>} catch (IOException e) {<br/> // TODO Auto-generated catch block <br/> e. printStackTrace (); <br/>} catch (XmlPullParserException e) {<br/> // TODO Auto-generated catch block <br/> e. printStackTrace (); <br/>}< br/> try {<br/> Object obj = envelope. getResponse (); <br/> System. out. println (String. valueOf (obj); <br/>} catch (SoapFault e) {<br/> // TODO Auto-generated catch block <br/> e. printStackTrace (); <br/>}

 

. NET end:

[WebMethod (Description = "test byte []")] <br/> public string XXXX (string condtion) <br/>{< br/> byte [] buffer = Convert. fromBase64String (condtion); // get byte [], you can do whatever you want <br/> return Encoding. UTF8.GetString (buffer); // type conversion is very important <br/>}

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.