Hi,

I am new Android and also to WebService.

I searched and found a samples of "Jorge Android Developer" for
webservice call from android.

I have created my own WSDL file and published using WebServer Tomcat
in Location
"http://localhost:8090/WebServiceTutorial/services/Hello?wsdl";

I checked this serviceusing the web browser and its worked fine. The
Problem is am not able to connect via android.

Problems faced:

1) first i got SocketException and i rectified by placing <uses-
permission  android:name="android.permission.INTERNET" />

2) Then i am getting ConnectException.I am not able to rectify
it.Please help me out from this.Thanks in advance.

My WSDL File:
============
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://tutorial.com";
xmlns:apachesoap="http://xml.apache.org/xml-soap"; xmlns:impl="http://
tutorial.com" xmlns:intf="http://tutorial.com"; xmlns:wsdl="http://
schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/
wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
 <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="http://
tutorial.com" xmlns="http://www.w3.org/2001/XMLSchema";>
   <element name="getMessage">
    <complexType>
     <sequence>
      <element name="name" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>
   <element name="getMessageResponse">
    <complexType>
     <sequence>
      <element name="getMessageReturn" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>
  </schema>
 </wsdl:types>

   <wsdl:message name="getMessageRequest">

      <wsdl:part element="impl:getMessage" name="parameters"/>

   </wsdl:message>

   <wsdl:message name="getMessageResponse">

      <wsdl:part element="impl:getMessageResponse" name="parameters"/>

   </wsdl:message>

   <wsdl:portType name="Hello">

      <wsdl:operation name="getMessage">

         <wsdl:input message="impl:getMessageRequest"
name="getMessageRequest"/>

         <wsdl:output message="impl:getMessageResponse"
name="getMessageResponse"/>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="HelloSoapBinding" type="impl:Hello">

      <wsdlsoap:binding style="document" transport="http://
schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="getMessage">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="getMessageRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="getMessageResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="HelloService">

      <wsdl:port binding="impl:HelloSoapBinding" name="Hello">

         <wsdlsoap:address location="http://localhost:8090/
WebServiceTutorial/services/Hello"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

My Java Class:
===========
package com.igt.mobile.booking.flightsearch;

import java.util.Vector;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.ImageButton;
import android.widget.Spinner;
import android.widget.TextView;


public class FlightSearch extends Activity {

        /* Web Service related variables Starts */
        private static final String SOAP_ACTION = ""; //This is empty because
WSDL file also having empty//
        private static final String METHOD_NAME = "getMessage";
        private static final String NAMESPACE = "http://tutorial.com";;
        private static final String URL = "http://localhost:8090/
WebServiceTutorial/services/Hello?wsdl";
        /* Web Service related variables Ends */


        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.flight_search);

                fetchValuesFromWebService();

        }

        private void fetchValuesFromWebService() {
                // CALL the web service method with the two parameters vname and
nname
                SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
                request.addProperty("name", "Braun");

                SoapSerializationEnvelope envelope = new 
SoapSerializationEnvelope(
                                SoapEnvelope.VER11);
                envelope.setOutputSoapObject(request);
                AndroidHttpTransport androidHttpTransport = new 
AndroidHttpTransport
(
                                URL);
                try {
                        androidHttpTransport.call(SOAP_ACTION, envelope);

                        // Get the SAOP Envelope back and the extract the body
                        SoapObject resultsRequestSOAP = (SoapObject) 
envelope.bodyIn;

                        SoapObject test = (SoapObject) resultsRequestSOAP
                                        .getProperty("getMessageReturn");

                        String tem = (String) test.toString();

                        // Just show it in a text area field called lblStatus
                        ((TextView) 
findViewById(R.string.departing)).setText(tem);

                } catch (Exception E) {
                        ((TextView) 
findViewById(R.string.departing)).setText("ERROR:"
                                        + E.getClass().getName() + ": " + 
E.getMessage());
                }
        }

}

My Android Manifest File:
==================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
      package="com.igt.mobile.booking.flightsearch"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/igtlogo"
                         android:label="@string/app_display_name">
        <activity android:name="FlightSearch">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="5" />
        <uses-permission  android:name="android.permission.INTERNET" />
</manifest>

Thanks again,
Parthiban.K
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to