1

So hi. I currently have web service that looks like this

    [WebMethod]
    public bool SyncGeneralDataToServer(string macaddress, string userid,
                                string password, string computername,
                                string dateupdated, string q1, string a1
                                , string q2, string a2, string q3, string a3
                                , string q4, string a4, string q5, string a5
                                , string location, bool onsite)
    {
        MTKBL = new MobileTKBL();
        bool result;
        try
        {
            result = MTKBL.SyncToServer(macaddress, userid,
                                     password, computername,
                                     dateupdated, q1, a1
                                    , q2, a2, q3, a3
                                    , q4, a4, q5, a5
                                    , location, onsite);
        }
        catch (Exception e)
        {
            result = false;
        }


        return result;
    }

And i have a android method that looks like this

        public boolean SyncLocalGeneralDataToServer(String macaddress, String userid,
        String password, String computername,
        String dateupdated, String q1, String a1
        , String q2, String a2, String q3, String a3
        , String q4, String a4, String q5, String a5
        , String location, boolean onsite)
{
    boolean result = false;

    String SOAP_ACTION = "http://MTKAndroidService.org/SyncGeneralDataToServer";
    String METHOD_NAME = "SyncGeneralDataToServer";

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);        

    PropertyInfo[] propInfos = new PropertyInfo[17];

    propInfos[0]= setPropertyInfo("macaddress",macaddress,String.class);
    propInfos[1]= setPropertyInfo("userid",userid,String.class);
    propInfos[2]= setPropertyInfo("macaddress",password,String.class);
    propInfos[3]= setPropertyInfo("computername",computername,String.class);
    propInfos[4]= setPropertyInfo("dateupdated",dateupdated,String.class);
    propInfos[5]= setPropertyInfo("q1",q1,String.class);
    propInfos[6]= setPropertyInfo("q2",q2,String.class);
    propInfos[7]= setPropertyInfo("q3",q3,String.class);
    propInfos[8]= setPropertyInfo("q4",q4,String.class);
    propInfos[9]= setPropertyInfo("q5",q5,String.class);
    propInfos[10]= setPropertyInfo("a1",a1,String.class);
    propInfos[11]= setPropertyInfo("a2",a2,String.class);
    propInfos[12]= setPropertyInfo("a3",a3,String.class);
    propInfos[13]= setPropertyInfo("a4",a4,String.class);
    propInfos[14]= setPropertyInfo("a5",a5,String.class);
    propInfos[15]= setPropertyInfo("location",location,String.class);
    propInfos[16]= setPropertyInfo("onsite",onsite,boolean.class);

    for(int i =0; i < propInfos.length; i++)
    {
         request.addProperty(propInfos[i]);
    }

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true; // put this only if the web service is .NET one
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {

        androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        Log.i("myApp", response.toString());
        if(response.toString().equalsIgnoreCase("true")){
            result = true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

private PropertyInfo setPropertyInfo(String name,Object value,Object type)
{
    PropertyInfo propInfo =new PropertyInfo();
    propInfo.setName(name);
    propInfo.setValue(value);
    propInfo.setType(type);
    return propInfo;
}

And ive checked the property info values are correct and complete. The problem is the web service accepts the request but inserts null values in the database. What am i missing here?

2
  • When you debugged the service, did you see the correct values in the variables going to this method? result = MTKBL.SyncToServer(macaddress, userid, password, computername, dateupdated, q1, a1 , q2, a2, q3, a3 , q4, a4, q5, a5 , location, onsite); Commented Aug 2, 2013 at 4:05
  • You mean in the browser locally? Yes it succesfully saves it in the database meaning it passed the values in the server. But if its from android no. All the values are null. Thats why im asking this question. Commented Aug 2, 2013 at 4:47

1 Answer 1

1
+50

Your namespace URL (both .net and android sides) probably has a colon in it, eg http:// - remove the http:// part from the namespace and try again.

Sign up to request clarification or add additional context in comments.

1 Comment

Well there was actually a wrong spelling in the url that caused the problem. Tnx for the heads up though. you directed me to check it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.