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