简体   繁体   中英

Facing some issues with soap web service. Entering the correct parameters as mentioned in WSDL

{Got error - Procedure or function 'ETI_User_Get_By_Email' expects parameter '@EMail_Address', which was not supplied.}

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

WSDL parameters - EmailAddress - String Transaction_Amount - Double

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

Android JAVA code below

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("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;
    }
}

}

Solution:

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;
    }
}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM