Возникли некоторые проблемы с мыльным веб-сервисом.Ввод правильных параметров, как указано в WSDL - PullRequest
0 голосов
/ 14 ноября 2018

{Ошибка получена - процедура или функция 'ETI_User_Get_By_Email' ожидает параметр '@EMail_Address', который не был предоставлен.}

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

Параметры WSDL - EmailAddress - String Transaction_Amount - Double

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

Код 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;
    }
}

}

1 Ответ

0 голосов
/ 16 ноября 2018

Решение:

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