Hi Android Dev. I'm quite new to android but I found my way up very
quickly. Thanks for providing the SDK. I have the following code:

package android.webservice.client;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.widget.TextView;
import android.app.Activity;
import android.os.Bundle;

import java.net.InetAddress;

public class AndroidWSClientActivity extends Activity {

        InetAddress ipAddress;
        private static final String NAMESPACE = "http://hello_webservice";;
        private String URL;
        private static final String METHOD_NAME = "hello";
        private static final String SOAP_ACTION = "http://hello_webservice/
hello";
        SoapObject request;
        private TextView lblResult;

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

                try{
                    ipAddress = InetAddress.getLocalHost();
                    URL = "http://"+ipAddress+":6220/WebServiceProject/services/
HelloWSImpl?wsdl";
                } catch(Exception e){
                }

                lblResult = (TextView) findViewById(R.id.result);

                request = new SoapObject(NAMESPACE, METHOD_NAME);
                request.addProperty("name", " Ntembeko"); //Add 3 Properties

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

                HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

                try {
                        androidHttpTransport.call(SOAP_ACTION, envelope);

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

                        lblResult.setText(resultsRequestSOAP.toString());

                } catch (Exception e) {
                }
        }
}

And what I want to do is to replace the IP address in the URL with a
dynamic address and use the variable "ipAddress" as I've done but when
I run it, I don't get any response from the Web Service and when I
make it static like "172......." I do get the responce from Web
Service. I'm running a local Tomcat Server on my Laptop. The reason
for using "ipAddress" is that sometimes I use VPN connection and
sometimes I connect directly to the Internet without the VPN and the
IP keeps on changing. When I put "localhost" as an address, still I
don't get any responce.

HOW CAN I DO THIS? I don't get any error messages that's why I didn't
post them but I don't get responce the service.

Thanks in advance.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to