【问题标题】:Facing some issues with soap web service. Entering the correct parameters as mentioned in WSDL面临肥皂网络服务的一些问题。输入 WSDL 中提到的正确参数
【发布时间】:2018-11-14 09:33:08
【问题描述】:

{出现错误 - 过程或函数“ETI_User_Get_By_Email”需要参数“@EMail_Address”,但未提供。}

/******************************/

WSDL 参数 - 电子邮件地址 - 字符串 Transaction_Amount - 双倍

/************************************/

Android JAVA 代码如下

公共类 MainActivity 扩展 AppCompatActivity {

EditText textBox1, textbox2;
Button button;
TextView text;

String URL = "hidden";
String NAMESPACE = "hidden";
String SOAP_ACTION = "hidden";
String METHOD_NAME = "VerifyETIWallet";
String PARAMETER_NAME1 = "EmailAddress";
String PARAMETER_NAME2 = "Transaction_Amount";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    textBox1 = (EditText)findViewById(R.id.textbox1);
    textbox2 = (EditText)findViewById(R.id.textbox2);
    button = (Button)findViewById(R.id.button);
    text = (TextView)findViewById(R.id.text);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new CallWebService().execute(textBox1.getText().toString(),textbox2.getText().toString());
        }
    });
}

class CallWebService extends AsyncTask<String, Void, String> {
    @Override
    protected void onPostExecute(String s) {
        text.setText("Result = " + s);
    }

    @Override
    protected String doInBackground(String... params) {
        String result = "";

        SoapObject soapObject = new SoapObject(NAMESPACE, METHOD_NAME);

        PropertyInfo propertyInfo1 = new PropertyInfo();
        propertyInfo1.setName(PARAMETER_NAME1);
        propertyInfo1.setValue(params[0]);
        propertyInfo1.setType(String.class);

        PropertyInfo propertyInfo2 = new PropertyInfo();
        propertyInfo2.setName(PARAMETER_NAME2);
        propertyInfo2.setValue(params[1]);
        propertyInfo2.setType(Double.class);

        soapObject.addProperty(propertyInfo1);
        soapObject.addProperty(propertyInfo2);

        SoapSerializationEnvelope envelope =  new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(soapObject);

        HttpTransportSE httpTransportSE = new HttpTransportSE(URL);

        try {
            httpTransportSE.call(SOAP_ACTION, envelope);
            SoapPrimitive soapPrimitive = (SoapPrimitive)envelope.getResponse();
            result = soapPrimitive.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }
}

}

【问题讨论】:

  • 嗯,错误信息说的都是Procedure or function ETI_User_Get_By_Email expects parameter @EMail_Address, which was not supplied.
  • 我按照 WSDL 参数传递。 soapObject.addProperty("EmailAddress", email.getText().toString()); soapObject.addProperty("Transaction_Amount", amount.getText().toString());

标签: java android soap parameters soapfault


【解决方案1】:

解决方案:

public class MainActivity extends AppCompatActivity {
EditText textBox1, textbox2;
Button button;
TextView text;

String URL = "hidden";
String NAMESPACE = "hidden";
String SOAP_ACTION = "hidden";
String METHOD_NAME = "VerifyETIWallet";
String PARAMETER_NAME1 = "EmailAddress";
String PARAMETER_NAME2 = "Transaction_Amount";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    textBox1 = (EditText)findViewById(R.id.textbox1);
    textbox2 = (EditText)findViewById(R.id.textbox2);
    button = (Button)findViewById(R.id.button);
    text = (TextView)findViewById(R.id.text);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new CallWebService().execute(textBox1.getText().toString(),textbox2.getText().toString());
        }
    });
}

class CallWebService extends AsyncTask<String, Void, String> {
    @Override
    protected void onPostExecute(String s) {
        text.setText(s);
    }

    @Override
    protected String doInBackground(String... params) {
        String result = "";

        SoapObject soapObject = new SoapObject(NAMESPACE, METHOD_NAME);

        PropertyInfo propertyInfo1 = new PropertyInfo();
        propertyInfo1.setName(PARAMETER_NAME1);
        propertyInfo1.setValue(params[0]);
        propertyInfo1.setType(String.class);
        Log.e("param 1",params[0]);
        PropertyInfo propertyInfo2 = new PropertyInfo();
        propertyInfo2.setName(PARAMETER_NAME2);
        propertyInfo2.setValue(params[1]);
        Log.e("param 2",params[1]);
        propertyInfo2.setType(Double.class);

        soapObject.addProperty(propertyInfo1);
        soapObject.addProperty(propertyInfo2);

        SoapSerializationEnvelope envelope =  new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(soapObject);

        HttpTransportSE httpTransportSE = new HttpTransportSE(URL);

        try {
            httpTransportSE.call(SOAP_ACTION, envelope);
            SoapPrimitive soapPrimitive = (SoapPrimitive)envelope.getResponse();
            result = soapPrimitive.toString();
            Log.e("result",result);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }
}
}

【讨论】:

    猜你喜欢
    • 2014-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-29
    • 2017-01-16
    • 2017-12-10
    • 1970-01-01
    相关资源
    最近更新 更多