8

我正在尝试使用一个 WSDL 文件调用 SOAP Web 服务。

我已经在其中添加了所有必需的参数。但我收到如下错误:

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

这是我的代码示例:

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", "XXXX@gmail.com");
            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();
    }
}

我怀疑 SOAPACTION 可能会导致问题。如果我们将 SOAPACtion 设为空白并调用 Web 服务,这可能吗?

我已经为其他 Web 服务使用了相同的代码,带有 .svc url,并且工作正常,所以我认为代码应该没有任何问题。

SOAP 版本:1.1 ksoap 库版本:ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar

任何帮助表示赞赏。

谢谢

4

2 回答 2

1

尝试替换result1 = (SoapPrimitive)envelope.getResponse();

result1 = (SoapPrimitive)envelope.bodyIn();  

并设置一个 SOAP_ACTION !
这也是您向请求添加属性的方式:

    PropertyInfo pi = new PropertyInfo();
    pi.name = NAME;
    pi.type = String.class;
    request.addProperty(pi, VALUE);
于 2014-08-01T09:04:55.773 回答
0

您需要检查 SOAP wsdl 是否具有哪种样式、文档或 RPC。

两者都有不同的 WSDL 格式,如果您尝试使用文档类型调用 WSDL,则可能无法使用相同的代码为其他格式提供响应。

所以请交叉检查并确认。

问候

于 2014-08-05T10:37:52.907 回答