开发者

calling .net web service from android not working

开发者 https://www.devze.com 2023-02-04 18:22 出处:网络
I am calling a .net web service from my android app with no luck. Here is my code: My packages: package com.reza;

I am calling a .net web service from my android app with no luck. Here is my code:

My packages:

package com.reza;

import android.app.Activity;
import android.os.Bundle;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.widget.TextView;

The class:

public class callWebservice extends Activity {
     private static final String METHOD_NAME = "HelloWorld";

     private static final String NAMESPACE = "http://tempuri.org/";
     private static final String URL = "http://service.screwedmind.com/LocalBusiness.asmx";
     private static final String SOAP_ACTION = null;
     TextView tv;

    /** Called when the activity is first 开发者_高级运维created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tv=(TextView)findViewById(R.id.text1);
        call();
    }
    public void call()
    {
            try {

            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

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

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

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

            tv.setText(result);
            } 
            catch (Exception e) {
                tv.setText("error occured..");
            }
    }
}

when I run this program, I see my error text which is "error occured..." can anybody plz guide me what i am doing wrong.


The "error occured.." is your error message, write tv.setText(e.toString()); and what message do you see there?


you probably only need to set SOAP_ACTION = NAMESPACE + METHOD_NAME


You should change SOAP_ACTION = NAMESPACE + METHOD_NAME

0

精彩评论

暂无评论...
验证码 换一张
取 消