无法在android中的另一个页面上使用Web服务的结果

时间:2012-08-29 07:00:58

标签: android eclipse web-services

我正在尝试使用以下链接使用网络服务

http://54.251.60.177/TMSWebService/MarginService.asmx

通过android的方法SOAP。 在这里我的问题是在从用户获得输入之后,然后在单击调用按钮之后它只是显示一个空白页面(即,什么都没有显示)。

注意:我检查了所有网络服务配置,我做得很完美,我觉得没错。

上述网络服务的输入值为

fd:01/01/2012

td:07/07/2012

此服务将以xml的形式返回值,但此处不显示任何内容。 任何人都可以告诉我这个问题吗?

下面的图片会让你清楚我的怀疑

enter image description here enter image description here

网络方法(注意:我猜我的网络方法的来源可能有问题)

public class GetTMSMargin 
{ 
private Object fd;
private Object td;

public GetTMSMargin(Object fd, Object td) {

    this.fd = fd;
    this.td = td;
}

public Object getFd() 
{
    return fd;
}

public Object getTd() 
{
    return td;
}
  }

Barchart.java

 public class Barchart extends Activity 
 {

Button btn;
EditText edt1,edt2;

@Override
   public void onCreate(Bundle savedInstanceState)
   {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);


       edt1 = (EditText)findViewById(R.id.editText1);
       edt2 = (EditText)findViewById(R.id.editText2);

       Button btn = (Button)findViewById(R.id.button1);
       btn.setOnClickListener(new View.OnClickListener()
       {

    @Override
    public void onClick(View v) 
    {

    if(edt1.getText().toString().length()!=0 && edt2.getText().toString().length()!=0 )
    {
    Intent myIntent = new Intent(v.getContext(), Main_activity.class);
    startActivity(myIntent);
    }
    else
    {
        Toast.makeText(getApplicationContext(), "Can't browse!..", Toast.LENGTH_SHORT).show();

}}});   }     }

Main_activity.java

 public class Main_activity extends Activity 
 {

/** Called when the activity is first created. */

private static final String SOAP_ACTION = "http://tempuri.org/GetTMSMargin";

private static final String METHOD_NAME = "GetTMSMargin";

private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://54.251.60.177/TMSWebService/MarginService.asmx?WSDL";

TextView tv;
EditText edt1,edt2;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main1);
    tv=(TextView)findViewById(R.id.textView_result);
    call();

}

public void call()
{
    try {

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        request.addProperty("fd",edt1.getText().toString());
        request.addProperty("td",edt2.getText().toString());

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

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.call(SOAP_ACTION, envelope);

        SoapPrimitive result = (SoapPrimitive)envelope.getResponse();

        tv.setText(result.toString());
    } catch (Exception e) {
        tv.setText(e.getMessage());
        }
   }   }

感谢您宝贵的时间!..

0 个答案:

没有答案