android - why my app crash when i try to post some data into web service? -


What I am doing is that I am trying to send some strings from my activity and post for a web service My code is like this:

  approve.setOnClickListener (New OnClickListener) {@SuppressWarnings ("uncontrolled") @Override Public Zero onClick (see v) {// TODO Automatic Created method stub // intent = new intent (Info.this, MainActivity.class); condition = "1"; ORDERNUMBER = "25", User ID = "11"; // AsyncCallWS AsyncCallWS function = new AsyncCallWS () Create an example for: // L'work performed. Execute ();}}); Personal class AsyncCallWS extends asyncTask {@Override protected object doInBackground (object ... parameter) {// TODO auto created method stub loginStatus = WebService.invokeLoginWS (status, ORDERNUMBER, User ID, "GetOrderData"); Return tap; } Secure Zero PostExecute (zero result) {// Create progressive invisible webservicePG.setVisibility bar (see. INVISIBLE); IntObj = new intent (notice.This, pending ordersers class); // Error status is false} // Show progress bar on protected Zero PreExecute () {webservicePG.setVisibility (see Visual.); }}   

And here is my web service class:

  package post; Import org.ksoap2.SoapEnvelope; Import org.ksoap2.serialization.PropertyInfo; Import org.ksoap2.serialization.SoapObject; Import org.ksoap2.serialization.SoapPrimitive; Import org.ksoap2.serialization.SoapSerializationEnvelope; Import org.ksoap2.transport.HttpTransportSE; Public class WebService {// Webservice namespace - WSDL Private Static String can be found in NAMESPACE = "http://service.programmerguru.com/"; // Websites URL - WSDL File Location Private Static String URL = "http://192.168.1.113/ Test Order / OrderAndroid.mx. / / Make sure you have changed the IP address / SOAP action URI again, + Namespace + Web method name personalized string SOAP_ACTION = "http://service.programmerguru.com/"; Public Static Boolean invokeLoginWS (string position, string order, string user name, string webMethName) {Boolean law GinStatus = Incorrect; // Request RequestSubbagg = New Duplicate (NAMESPACE, webMethName); // property that holds the input parameters PropertyInfo statusPI = New PropertyInfo (); PropertyInfo OrderIdpi = New propertyInfo (); PropertyInfo Username PI = New Property Info (); // Set Username PI.setName ("status"); // Set Value Position PI.setValue (Status); // Set DataType Status PI.setType (String.class); // object request Add property to request .addProperty (statusPI); // Set password orderseed PI.setName ("orderid"); // Set Data Type PI.setValue (orderid); // Set Datatype Ordrid PI.Set Type (string class); // add property to request.addProperty object (orderidPI); UsernamePI.setName ("username"); // Set DataType Username PI.setValue (user name); // set datatype username PI.setType (String.class); // add property to request request.addProperty (usernamePI); // Create envelope soap certification envelope envelope = new soap substitution Anaph (sophonffe. Over 11); // set output SOAP object envelope.SetOptputShipObject (request); // Create HTTP Call Objects HTTPTRSSRS Android HTTPRSport = New HTTPS TranssectionSE (URL); {// Web service endocrare HTTPAport Call (SOAP_ACTION + webMethName, envelope); // Receive Response SoapPrimitive Response = (Soapprimmic) Envelope .getResponse (); // Assign it to a Boolean variable change Status = Boolean.parseBoolean (response.toString ()); } Catch (Exception E) {// Static Variable 'errored' Specify the error status correct in e.printStackTrace (); } // Return to Object Returns Launch Status; }}   

And when I press the approval button and my activity is an accident, I see some of the lockbacks:

  Fatal exception: the main Java com.example.newmaamoontest.Info $ AsyncCallWS.onPreExecute (Info.java:151) android.os.AsyncTask.executeOnExecutor (AsyncTask.java:586) .lang.NullPointerException (AsyncTask on android.os.AsyncTask.execute .java: 534) Your webservice PG View Variables are not started.    

You are trying to call the method without extending the object. Try to start and install webservicePG in the onCreate method using webservicePG = findViewById (R.id.your_id); Or if you are creating dynamic webservicePG = new view (this);

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -