Android Soap Webservers Unable to perform error ht.call (soap_action, envelope); workaround

Source: Internet
Author: User

1. May not be added to the network access, manifest inside, <uses-permission android:name= "Android.permission.INTERNET"/>

2. Version issue, it is possible that the problem, because Android above 9 will go wrong, so the simple and rude way is to directly the version information

<uses-sdk
Android:minsdkversion= "? "
Android:targetsdkversion= "?"

/>

Delete.

Other specific reference codes are as follows:

1  Packagecom.example.soaptestforandroid;2 3 Importjava.io.IOException;4 5 ImportOrg.ksoap2.SoapEnvelope;6 ImportOrg.ksoap2.serialization.SoapObject;7 ImportOrg.ksoap2.serialization.SoapSerializationEnvelope;8 ImportOrg.ksoap2.transport.HttpTransportSE;9 Importorg.xmlpull.v1.XmlPullParserException;Ten  One Importandroid.os.*; A ImportAndroid.annotation.SuppressLint; - Importandroid.app.Activity; - ImportAndroid.util.Log; the ImportAndroid.view.Menu; - Importandroid.widget.*; -  -  Public classMainactivityextendsActivity + { -  +     Private Static FinalString service_namespace = "http://services.jason.com/"; A     Private Static FinalString Service_url = "HTTP://172.16.1.164:8080/MYWEBSERVER/USERINFOPORT?WSDL"; at     PrivateEditText TV =NULL; -      -      -      -@SuppressLint ("Newapi") - @Override in     protected voidonCreate (Bundle savedinstancestate) -     { to         Super. OnCreate (savedinstancestate); + Setcontentview (r.layout.activity_main); -          the          *         Try { $TV =(EditText) Findviewbyid (R.id.hello);Panax Notoginseng          -         //if the system is more than 4.0 (build.version_codes. Ice_cream_sandwich for android4.0) the         if(Build.VERSION.SDK_INT >Build.version_codes. Ice_cream_sandwich) { +             //See Strictmode documentation AStrictmode.setthreadpolicy (NewStrictMode.ThreadPolicy.Builder () the . Detectdiskreads (). Detectdiskwrites (). Detectnetwork () + . Penaltylog (). build ()); -Strictmode.setvmpolicy (NewStrictMode.VmPolicy.Builder () $ . Detectleakedsqlliteobjects (). Detectleakedclosableobjects () $ . Penaltylog (). Penaltydeath (). build ()); -         } -  the         //method to invoke -String mathodname = "GetUserInfo";WuyiString soap_action = Service_namespace +Mathodname; the         //Create a Httptransportse object -Httptransportse HT =NewHttptransportse (service_url); Wu          -Ht.debug =true; About             //creating a Envelop object using the SOAP protocol $Soapserializationenvelope envelope =NewSoapserializationenvelope ( - soapenvelope.ver10); -             //instantiating a Soapobject object -Soapobject Object =NewSoapobject (Service_namespace, mathodname); A             //set the Soapobject object to an outgoing SOAP message for the Soapserializationenvelope object +Envelope.bodyout =object; theEnvelope.dotnet =true; - Envelope.setoutputsoapobject (object); $                 //Call WebService the Ht.call (soap_action, envelope); theSystem.out.println ("Envelope.getresponse ()---" the+envelope.getresponse ()); the                 if(Envelope.getresponse ()! =NULL) { -              inSoapobject result =(Soapobject) Envelope.bodyin; theString name = Result.getproperty (0). toString (); the System.out.println (name); AboutTv.settext ("Return value is:" +name); the                      the}Else { theTv.settext ("No Return value"); +                 } -}Catch(Exception e) { the                 //TODO auto-generated Catch blockBayi e.printstacktrace (); the             }  the          -     } -  the @Override the      Public BooleanOncreateoptionsmenu (Menu menu) the     { the         //inflate the menu; This adds items to the action bar if it is present. - getmenuinflater (). Inflate (R.menu.main, menu); the         return true; the     } the 94}
View Code

Android Soap Webservers Unable to perform error ht.call (soap_action, envelope); workaround

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.