Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException:

I am using soap base web service.. I used this example n I am able to do parsing and get response but when I try for different one by making some change in that. I am getting below mentioned errors in my project my code is below pls take a look..

public class MainActivity extends ActionBarActivity implements OnClickListener {

    TextView tv1;
    EditText edname, edemail, edpassword;
    Button btnSubmit;
    private final String NAMESPACE = "http://tempuri.org/";
    private final String URL = "http://208.109.86.236:8080/API.asmx";
    private final String SOAP_ACTION = "http://tempuri.org/PlayerSignup";
    private final String METHOD_NAME = "PlayerSignup";
    private String TAG = "PGGURU";
    private static String stusername;
    private static String stpassword;
    private static String stemail;
    private static String responsea;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv1 = (TextView) findViewById(R.id.tv1);
        edname = (EditText) findViewById(R.id.editText1);
        edpassword = (EditText) findViewById(R.id.editText2);
        edemail = (EditText) findViewById(R.id.editText3);
        btnSubmit = (Button) findViewById(R.id.button1);
        btnSubmit.setOnClickListener(this);
        // throw new RuntimeException();
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        if (edname.getText().toString() != ""
                && edpassword.getText().toString() != ""
                && edemail.getText().toString() != "") {
            stusername = edname.getText().toString();
            stpassword = edpassword.getText().toString();
            stemail = edemail.getText().toString();
            Log.i("username", stusername);
            Log.i("password", stpassword);
            Log.i("email", stemail);
            AsyncCallWS task = new AsyncCallWS();
            // Call execute
            task.execute();
        } else {
            tv1.setText("Please enter Celcius");
        }
    }

    private class AsyncCallWS extends AsyncTask<String, Void, Void> {
        @Override
        protected Void doInBackground(String... params) {
            Log.i(TAG, "doInBackground");
            getFahrenheit(stusername, stpassword, stemail);
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            Log.i(TAG, "onPostExecute");
            tv1.setText(responsea);
        }

        @Override
        protected void onPreExecute() {
            Log.i(TAG, "onPreExecute");
            tv1.setText("Calculating...");
        }

        @Override
        protected void onProgressUpdate(Void... values) {
            Log.i(TAG, "onProgressUpdate");
        }

    }

    public void getFahrenheit(String name, String password, String email) {
        // Create request

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        // Property which holds input parameters
        PropertyInfo celsiusPI = new PropertyInfo();
        // Set Name
        celsiusPI.setName("Username");
        // Set Value
        celsiusPI.setValue(stusername);

        celsiusPI.setName("Password");
        // Set Value
        celsiusPI.setValue(stpassword);

        celsiusPI.setName("Email");
        // Set Value
        celsiusPI.setValue(stemail);

        // Set dataType
        celsiusPI.setType(String.class);
        // Add the property to request object
        request.addProperty(celsiusPI);
        // Create envelope
        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 {
            // Invole web service
            Log.i("aaaa", "aaaaaaaaaaa");
            androidHttpTransport.call(SOAP_ACTION, envelope);
            Log.i("bbbb", "bbbbbbbbbbbbbbb");
            // Get the response
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            // SoapObject response = (SoapObject) envelope.getResponse();
            // Object result= (Object)envelope.getResponse();
            Log.i("cccc", "ccccccccccccc");
            // Assign it to fahren static variable
            responsea = response.toString();
            Log.i("dddd", "dddddddddddd");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

I am getting exception on this line

SoapPrimitive response = (SoapPrimitive) envelope.getResponse();

Logcat:

11-10 17:24:22.108: I/username(25790): fgg
11-10 17:24:22.108: I/password(25790): fhgg
11-10 17:24:22.108: I/email(25790): cbbb
11-10 17:24:22.108: I/PGGURU(25790): onPreExecute
11-10 17:24:22.108: I/PGGURU(25790): doInBackground
11-10 17:24:22.108: I/aaaa(25790): aaaaaaaaaaa
11-10 17:24:23.480: I/bbbb(25790): bbbbbbbbbbbbbbb
11-10 17:24:23.480: W/System.err(25790): SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException: String reference not set to an instance of a String.
11-10 17:24:23.480: W/System.err(25790): Parameter name: s
11-10 17:24:23.480: W/System.err(25790):    at System.Text.Encoding.GetBytes(String s)
11-10 17:24:23.480: W/System.err(25790):    at IndiablWebService.Helper.CryptorEngine.Encrypt(String toEncrypt, Boolean useHashing) in C:\Users\DIGICOM\Desktop\IndiablWebService_New1\IndiablWebService_New_from office\IndiablWebService\Helper\CryptorEngine.cs:line 22
11-10 17:24:23.480: W/System.err(25790):    at IndiablWebService.API.DokPlayerSignup(String Username, String Password, String Email, String Question, String Answer) in C:\Users\DIGICOM\Desktop\IndiablWebService_New1\IndiablWebService_New_from office\IndiablWebService\API.asmx.cs:line 124
11-10 17:24:23.480: W/System.err(25790):    at IndiablWebService.API.PlayerSignup(String Username, String Password, String Email) in C:\Users\DIGICOM\Desktop\IndiablWebService_New1\IndiablWebService_New_from office\IndiablWebService\API.asmx.cs:line 87
11-10 17:24:23.480: W/System.err(25790):    --- End of inner exception stack trace ---' faultactor: 'null' detail: org.kxml2.kdom.Node@4181f468
11-10 17:24:23.480: W/System.err(25790):    at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:112)
11-10 17:24:23.480: W/System.err(25790):    at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:137)
11-10 17:24:23.480: W/System.err(25790):    at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
11-10 17:24:23.480: W/System.err(25790):    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
11-10 17:24:23.480: W/System.err(25790):    at com.example.soap_demo2.MainActivity.getFahrenheit(MainActivity.java:136)
11-10 17:24:23.480: W/System.err(25790):    at com.example.soap_demo2.MainActivity$AsyncCallWS.doInBackground(MainActivity.java:74)
11-10 17:24:23.480: W/System.err(25790):    at com.example.soap_demo2.MainActivity$AsyncCallWS.doInBackground(MainActivity.java:1)
11-10 17:24:23.480: W/System.err(25790):    at android.os.AsyncTask$2.call(AsyncTask.java:288)
11-10 17:24:23.480: W/System.err(25790):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
11-10 17:24:23.480: W/System.err(25790):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
11-10 17:24:23.480: W/System.err(25790):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
11-10 17:24:23.480: W/System.err(25790):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
11-10 17:24:23.480: W/System.err(25790):    at java.lang.Thread.run(Thread.java:841)
11-10 17:24:23.480: I/PGGURU(25790): onPostExecute
like image 420
Abhishek Avatar asked Feb 11 '23 14:02

Abhishek


1 Answers

I just navigated to http://208.109.86.236:8080/API.asmx?op=PlayerSignup and executed a test request. I got this response:

{"LoginStatus":true,"Message":"Successfully Registered","AccessToken":"dfUW4Xq8u1w="}

This is JSON. The SOAP protocol operates on XML. You need to change your server to return data in the appropriate XML schema.

like image 193
JstnPwll Avatar answered Feb 26 '23 21:02

JstnPwll