1

嗨,我正在尝试从使用 ksoap2 for android 的网站读取信息,但每当我尝试我的应用程序强制关闭时。我已将站点的方法从教程更改为站点,因此该站点应该不是问题,下面是我拥有的代码。这是我的第一篇文章,如果我犯了任何错误,非常抱歉谢谢

public class SharepointappActivity extends Activity {


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
Button gobutton = (Button)findViewById(R.id.button1);
  gobutton.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {
        // TODO Auto-generated method stub
        boom();
    }
});

}
public void boom(){
      final TextView text1 = (TextView)findViewById(R.id.textView1);
String NAMESPACE = "http://footballpool.dataaccess.eu";
String METHOD_NAME = "StadiumInfo";
String SOAP_ACTION = "http://footballpool.dataaccess.eu/data/";
String URL = "http://footballpool.dataaccess.eu/data/info.wso?WSDL";

SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);




Request.addProperty("sStadiumName", "Free State Stadium"); 



SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(Request);

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

try
{
   androidHttpTransport.call(SOAP_ACTION, envelope);
   SoapObject response = (SoapObject)envelope.getResponse();
 int result =  Integer.parseInt(response.getProperty(0).toString());
//    Object result2 = envelope.getResponse();
 text1.setText(result);
}
  catch(Exception e)
 {
     e.printStackTrace();
 }
  }
}
4

1 回答 1

0

您需要将“”添加到 SOAP_ACTION。

String.format( "\"http://yournamespace/%s\"", method );
于 2012-05-29T20:22:59.110 回答