KSOAP2 Web服务连接

时间:2011-08-09 19:39:52

标签: android ksoap2 android-ksoap2

我尝试连接我的.net网络服务,但是我收到的错误就像“路径中的非法字符”。我怎么能摆脱它?

由于

package com.soap.test;

import android.app.Activity;
import android.database.CursorJoiner.Result;
import android.os.Bundle;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.ksoap2.transport.HttpsTransportSE;

import android.widget.TextView;

public class SOAPActivity extends Activity {
/** Called when the activity is first created. */
private static final String SOAP_ACTION="http://tempuri.org/UserLogin";
private static final String METHOD_NAME="UserLogin";
private static final String NAMESPACE="http://tempuri.org";
private static final String URL="../system.asmx";
TextView tv;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    tv=(TextView)findViewById(R.id.textView1);

    SoapObject Request = new SoapObject(NAMESPACE,METHOD_NAME);
    Request.addProperty("iUserName","soft");
    Request.addProperty("iPassword","12345");
    System.setProperty("http.keepAlive", "false");

    SoapSerializationEnvelope soapEnvelope= new SoapSerializationEnvelope(SoapEnvelope.VER11);
    soapEnvelope.dotNet=true;


    HttpsTransportSE  aht= new HttpsTransportSE(URL,443,"",1000);
    aht.debug=true;
    try
    {
        aht.call(SOAP_ACTION, soapEnvelope);

        SoapObject result=(SoapObject)soapEnvelope.getResponse();

        //to get the data
        String resultData=result.getProperty(0).toString();
        tv.setText("String" + resultData);
    }
    catch(Exception e)
    {
        tv.setText(e.toString());
    }
}
}

0 个答案:

没有答案