0

I am using an web service to store multiple values in database. I have created the code but was not able to store the values in remote database. There is no error in the code but instead of the the values are not storing in database.

Here is my code:-

public String registerDoctor(String MethodName,Pojo p)
        {
            try 
            {
               SOAP_ACTION = namespace + MethodName;

               //Adding values to request object
               request = new SoapObject(namespace, MethodName);


               PropertyInfo registerDoctors =new PropertyInfo();

               //doctor name
               Log.v("name", p.getDoctorName().toString());
               registerDoctors.setName("doctorName");
               registerDoctors.setValue(p.getDoctorName());
               registerDoctors.setType(string.class);

             //doctor qualification
               Log.v("qualification", p.getQualification().toString());
               registerDoctors.setName("qualificaion");
               registerDoctors.setValue(p.getQualification());
               registerDoctors.setType(string.class);

             //doctor specialization
               Log.v("specialization", p.getSpecialization().toString());
               registerDoctors.setName("specialization");
               registerDoctors.setValue(p.getSpecialization());
               registerDoctors.setType(string.class);

             //doctor cityId
               Log.v("cityid", p.getCityId().toString());
               registerDoctors.setName("cityId");
               registerDoctors.setValue(p.getCityId());
               registerDoctors.setType(integer.class);

             //doctor areaId
               Log.v("areaid", p.getAreaId().toString());
               registerDoctors.setName("doctorName");
               registerDoctors.setValue(p.getAreaId());
               registerDoctors.setType(integer.class);


             //doctor phoneNo
               Log.v("phone", p.getPhoneNo().toString());
               registerDoctors.setName("phoneNo");
               registerDoctors.setValue(p.getPhoneNo());
               registerDoctors.setType(string.class);

             //doctor mobile1
               Log.v("mobile1", p.getMobile().toString());
               registerDoctors.setName("mobile1");
               registerDoctors.setValue(p.Mobile);
               registerDoctors.setType(string.class);

             //doctor mobile2
               Log.v("mobile2", p.getMobile2().toString());
               registerDoctors.setName("mobile2");
               registerDoctors.setValue(p.getMobile2());
               registerDoctors.setType(string.class);


               request.addProperty(registerDoctors);

               SetEnvelope();

                   try 
                   {

                            //SOAP calling webservice
                            androidHttpSE.call(SOAP_ACTION, envelope);

                            //Got Webservice response
                            String result = envelope.getResponse().toString();

                            Log.v("add log", result);
                            return result;

                        } 

                   catch (Exception e) 
                    {
                           // TODO: handle exception
                           return e.toString();
                    }

             }

            catch (Exception e) 
            {
                // TODO: handle exception
                return e.toString();
            }               
    }
Pravesh
  • 822
  • 1
  • 8
  • 20

2 Answers2

0

Send an ArrayList PropertyInfo to Server. Change the server side to receive ArrayList of PropertyIfo. I hope it helps.

Ranjithkumar
  • 697
  • 6
  • 16
0

Check the query,soapaction,namespace,method name and url at webservice properly. and then use below method.Its much simple and better

public static boolean regist(String Student_Name,String Last_Name,String Email_ID,String Mobile_Number,
                                 String Name_Of_The_College,String Qualification,String Location,String Fellowship,String Reference,
                                 String FeeStatus,String Slatitude,String Slongitude,String webMethName)
    {

        String registerresponse="flag";
        Email_ID="Blank";
        Location="Blank";


        String URL ="your url";
        String METHOD_NAMEREG = "your method name";
        String NamespaceR="your namespace", SOAPACTIONREG="your action";

        try{



            //long FellowshipL = Long.valueOf(Fellowship);

            SoapObject request = new SoapObject(NamespaceR, METHOD_NAMEREG);
//Note:"Candidate_Name" is property name mentioned in your webservice
//Student_Name is your value that to be inserted

            request.addProperty("Candidate_Name", Student_Name);
            request.addProperty("LastName", Last_Name);
            request.addProperty("email", Email_ID);
            request.addProperty("Mobile", Mobile_Number);
            request.addProperty("College_Name", Name_Of_The_College);
            request.addProperty("Qualification", Qualification);
            request.addProperty("Location", Location);
            request.addProperty("Fellowshipid", FellowshipL);
            request.addProperty("referenceName", Reference);
            request.addProperty("FeesStatus", FeeStatus);

            request.addProperty("lat",Slatitude);
            request.addProperty("lon",Slongitude);
//      request.addProperty("to", 9);

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            //Set output SOAP object
            envelope.setOutputSoapObject(request);
            //Create HTTP call object
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

            try
            {

                androidHttpTransport.call(SOAPACTIONREG, envelope);
                //  Log.i(TAG, "GetAllLoginDetails is running");
//        result1 = (Vector<SoapObject>) envelope.getResponse();
                SoapPrimitive  response = (SoapPrimitive ) envelope.getResponse();
                Log.i("string value at resp",response.toString());

                registerresponse=response.toString();

            }
            catch (Throwable t) {
                //Toast.makeText(MainActivity.this, "Request failed: " + t.toString(),
                //    Toast.LENGTH_LONG).show();
                Log.e("request fail", "> " + t.getMessage());
            }
        }catch (Throwable t) {
            Log.e("UnRegister Receiver Err", "> " + t.getMessage());

        }

        if(registerresponse.equals("Record Saved."))
        {return true;}
        else
        {return false;}
    }
Deepa MG
  • 188
  • 1
  • 15