0

I am unable to save values into my webserver which is in .net. i have use the following code but i got the follow in error in emulator..i.e..,

Server was unable to process request---> cannot insert the value null into column 'Name', table 'MyWorldApp.dbo.tbl_UserRegistration';column doesnot allow nulls.INSERT fails. The Statement has been terminated.

i have use the following link: http://113.193.181.53/MyWorldApp/Service1.asmx?op=InsertUsertRegistrationDetails

my code is:

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.*;
    import android.os.*;
    import android.util.Log;
    import android.widget.TextView;

    public class MyworldActivity extends Activity {
        /** Called when the activity is first created. */

        private static final String SOAP_ACTION = "http://localhost/service1/InsertUsertRegistrationDetails";

        private static final String METHOD_NAME = "POST";

        private static final String NAMESPACE = "http://localhost/service1";
        private static final String URL = "http://113.193.181.53/MyWorldApp/Service1.asmx";



        TextView tv;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            tv=(TextView)findViewById(R.id.text1);
            call();

        }

        public void call()
        {
            try {

                SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

                request.addProperty("Name", "'Rajapandian'");
                request.addProperty("UserName", "Rajapandian");
                request.addProperty("Password", "123");
                request.addProperty("MobileNumber", "456");
                request.addProperty("EmailID", "[email protected]");
                request.addProperty("image", "http://www.thehindu.com/multimedia/dynamic/00880/INDIA_CORRUPTION_PR_880168f.jpg");
                Log.e("success","success");
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                envelope.dotNet=true;
                envelope.setOutputSoapObject(request);

                HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
                androidHttpTransport.call(SOAP_ACTION, envelope);

                Object result = (Object)envelope.getResponse();

                tv.setText(result.toString());
            } catch (Exception e) {
                tv.setText(e.getMessage());
                }
        }
    }

can anyone tell me where i have done wrong..

thanks in advance..

0

3 Answers 3

2

Instead of

Object result = (Object)envelope.getResponse();

try this

SoapObject response= (SoapObject) envelope.bodyIn;
Sign up to request clarification or add additional context in comments.

Comments

0

here is the solution, in this example i have use get method.just pass your variable in url string

String url = "http://113.193.181.53/MyWorldApp/Service1.asmx/InsertUsertRegistrationDetails?Name=string&UserName=string&Password=string&MobileNumber=string&EmailID=string&image=string"

URL sourceUrl = new URL(url);
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
            Handler1 dataHandler = new Handler1();
            xr.setContentHandler(dataHandler);
            xr.parse(new InputSource(sourceUrl.openStream()));
            Dataset dataset = dataHandler.getParsednewJobdtl_DataSet();

Dataset :

package com.RecordingApp;

public class AuthDataset {



    private String booleanx = null;

    public void setbooleanx (String booleanx ) {
        this.booleanx = booleanx ;
    }

    public String getbooleanx () {
        return booleanx ;
    }


}

Handler:

package com.RecordingApp;

import java.util.ArrayList;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class AuthHandler extends DefaultHandler {
    boolean int1 = false;

    ArrayList ar1 = new ArrayList();

    ArrayList br1 = new ArrayList();

    private AuthDataset mysitelist = new AuthDataset();

    public AuthDataset getParsednewJobdtl_DataSet() {
        return this.mysitelist;
    }

    public void startDocument() throws SAXException {
        this.mysitelist = new AuthDataset();
    }

    @Override
    public void endDocument() throws SAXException {
    }

    // ***********************Start Element********************
    @Override
    public void startElement(String namespaceURI, String localName,
            String qName, Attributes atts) throws SAXException {
        if (localName.equals("boolean ")) {
            this.int1 = true;
        }

    }

    // ***********************End element********************
    @Override
    public void endElement(String namespaceURI, String localName, String qName)
            throws SAXException {
        if (localName.equals("boolean ")) {
            this.int1 = false;

        }
    }

    // ***********************character********************
    @Override
    public void characters(char ch[], int start, int length) {
        if (this.int1) {
            mysitelist.setbooleanx(new String(ch, start, length));
            ar1.add(new String(ch, start, length));
            setbooleanx (ar1);

        }

    }

    public void setbooleanx (ArrayList ar1) {
        this.br1 = ar1;
    }
    public ArrayList getbooleanx () {

        return br1;
    }

}

2 Comments

k thank u... how can i retrive my stored values from 113.193.181.53/MyWorldApp/…
i cant able to do that because its your turn to do something ... if you got any problem then tell me
0

Server was unable to process request---> cannot insert the value null into column 'Name', table 'MyWorldApp.dbo.tbl_UserRegistration';column doesnot allow nulls.INSERT fails. The Statement has been terminated.

Above is your error. You are inserting null value in the field name and name is set for not accept null values

  • So modify database table
  • or compulsory add not null values in the name field

Edit

Your method to post the values to the webservice is sending null values to the server

Comments

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.