带有ksoap2的Android Web服务

时间:2012-02-01 15:12:45

标签: android web-services wsdl android-ksoap2

我有一个wsdl文件网站,我想得到一些服务。 我的问题是:如何找到这些参数:

SOAP_ACTION
METHOD_NAME
NAMESPACE
URL

这是我的代码,但我有连接问题:

public class TestBookSoapActivity extends Activity {

private static final String SOAP_ACTION = "http://api.mdpi.com/ws/GetVersionInfo";
private static final String METHOD_NAME = "GetVersionInfo";
private static final String NAMESPACE = "http://api.mdpi.com/ws/";
private static final String URL = "http://api.mdpi.com/ws/mdpi.wsdl";


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    executeAppelSOAP();

}
private void executeAppelSOAP() {
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    request.addProperty("arg0", "10");


    SoapSerializationEnvelope enveloppe = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    enveloppe.setOutputSoapObject(request);
    AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport (URL);             
    try {
        androidHttpTransport.call(SOAP_ACTION, enveloppe);
        Object resultat = enveloppe.getResponse();
        System.out.println("Version = " + resultat.toString());
    } catch(Exception e) {
        e.printStackTrace();
        System.out.println("Problem");
    }
}
}

1 个答案:

答案 0 :(得分:1)

使用Soap-Ui http://www.soapui.org/获取问题的答案。然后相应地修改你的Android代码......