繁体   English   中英

肥皂网络服务面临一些问题。 输入WSDL中提到的正确参数

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

{发生错误-过程或函数'ETI_User_Get_By_Email'期望参数'@EMail_Address',但未提供。}

/ ********* /

WSDL参数-EmailAddress-字符串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;
    }
}

}

解:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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