8

I am trying to call SOAP web service using one WSDL file.

I have added all required parameters in it. But I am getting error as below:

SoapFault - faultcode: 'ns1:unexpected-error' faultstring: 'Fault occurred while processing.' faultactor: 'null' detail: null in android

Here is my code sample:

class RegisterMember extends AsyncTask<Void, Void, Void> {
    String SOAP_ACTION =  "";
    String METHOD_NAME = "registerMember";
    String NAMESPACE = "http://XXXXX.XX"; 
    String URL="http://XXXX.XX?WSDL";

    SoapPrimitive result1;
    String str;
    @Override
    protected void onPreExecute() {
        mProgressDialog = new ProgressDialog(MainActivity.this);
        mProgressDialog.setMessage("Checking For Activation");
        mProgressDialog.show();
    }

    @Override
    protected Void doInBackground(Void... params) {
        try {
            StringBuffer sb;
            SoapObject request=new SoapObject(NAMESPACE, METHOD_NAME);

            request.addProperty("name", "XXXX");
            request.addProperty("email", "[email protected]");
            request.addProperty("username", "XXXXX");
            request.addProperty("password", "XXXX");
            request.addProperty("mobile", "XXXXXXX");
            request.addProperty("pin", "XXXX");
            request.addProperty("dob", "XX/XX/XXXX");
            request.addProperty("gender", "male");
            request.addProperty("address", "XXXXX");
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);

            envelope.bodyOut = request;
            Log.d("In try","In Try");
            HttpTransportSE ht = new HttpTransportSE(URL);

            ht.call(NAMESPACE+METHOD_NAME, envelope);
            Log.d("In try","In Try1");
            result1 = (SoapPrimitive)envelope.getResponse();
            //SoapObject resultObj =  (SoapObject)envelope.getResponse();
            /*int numProp = resultObj.getPropertyCount();

            sb = new StringBuffer();
            for(int jj=0; jj<numProp; jj++) {
                sb.append((String) resultObj.getProperty(jj) + "\n");
                Log.d("For Loop", String.valueOf(sb.append((String) resultObj.getProperty(jj))));
            }*/

            Log.d("Envelope", String.valueOf(result1));
            // str = envelope.getResponse();
            // status= Boolean.valueOf(result1.toString());
            // str = result1.toString();
            Log.w("String Response of CheckActivation Status - - - - - - - - - -", str);
            Log.w("CheckActivation Status - - - - - - - ->>>>>>>>>", String.valueOf(result1));
        } catch (Exception e) {
            Log.d("No Data Found",e +"");
        }

        try {
            Thread.sleep(1000);
        } catch(Exception ex) {

        }

        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        // TODO Auto-generated method stub
        super.onPostExecute(result);

        Log.d("Response = = = = =",String.valueOf(result));

        mProgressDialog.dismiss();
    }
}

I doubt that the SOAPACTION might be causing issue. Is that possible if we have SOAPACtion blank and we call web service?

I have used same code for other web service, with .svc url, and works fine, so I dont think code should have any problem.

SOAP version:1.1 ksoap library version: ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar

Any help is appreciated.

Thanks

1
  • Error suggest that you have error because you are processing null data. Commented Aug 1, 2014 at 9:06

2 Answers 2

1

Try replacing result1 = (SoapPrimitive)envelope.getResponse();by

result1 = (SoapPrimitive)envelope.bodyIn();  

and also set a SOAP_ACTION !
Also this is how you add a property to the request :

    PropertyInfo pi = new PropertyInfo();
    pi.name = NAME;
    pi.type = String.class;
    request.addProperty(pi, VALUE);
3
  • I change the code as per your suggestion and getting this eroor now and I also set the SOAP_ACTION as NAMESPACE + METHOD_NAME java.lang.ClassCastException: org.ksoap2.SoapFault cannot be cast to org.ksoap2.serialization.SoapObject So please advice so i can move further Commented Aug 1, 2014 at 9:20
  • If you have got your .wsdl file, put it in the SoapUI soft, you will be able to simulate request to the webservice, and also get informations like SOAP_ACTION etc...
    – Jonsmoke
    Commented Aug 1, 2014 at 9:23
  • @ bumblebeez I already try your code to change as per your edit but still i m getting same error Fault occurred while processing. Please advice Commented Aug 1, 2014 at 10:26
0

You need to check whether SOAP wsdl has which style, document or RPC.

both have different WSDL format, and it may possible, if you try to call WSDL with document type, might not give response with same code work for other one.

So please cross check this and confirm.

Regards

2
  • i already check this and try to call web service of same type but document or RPC but still i didn't found any solution please advice more to solved this problem Commented Aug 6, 2014 at 10:07
  • I am now getting the soapfault error like "java.lang.RuntimeException: Cannot serialize:" please advice if any solution Commented Aug 6, 2014 at 12:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.