Can you avoid using SOAP to use REST?

You'd have much less to worry about if you're still building the web
service and use RESTlet!

tonytony

On May 15, 10:26 pm, zero4infinitive <[email protected]>
wrote:
> Hello,
>
> I have tried to connect web service thru ksoap2. I give a sample
> details:
>
> Request Object:
>
> <?xml version="1.0" encoding="utf-8"?>
> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap="http://
> schemas.xmlsoap.org/soap/envelope/">
>  <soap:Body>
>    <FetchCompanyData xmlns="http://tempuri.org/";>
>      <companyname>string</companyname>
>      <country>string</country>
>      <zipcode>string</zipcode>
>    </FetchCompanyData>
>  </soap:Body>
> </soap:Envelope>
>
> Response Object:
>
> <?xml version="1.0" encoding="utf-8"?>
> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap="http://
> schemas.xmlsoap.org/soap/envelope/">
>  <soap:Body>
>    <FetchCompanyDataResponse xmlns="http://tempuri.org/";>
>      <FetchCompanyDataResult>
>        <xsd:schema>schema</xsd:schema>xml</FetchCompanyDataResult>
>    </FetchCompanyDataResponse>
>  </soap:Body>
> </soap:Envelope>
>
> Schema :
>
> - <FetchCompanyDataResponse xmlns="http://tempuri.org/";>
> - <FetchCompanyDataResult>
> - <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/
> 2001/
> XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> xmlns:msprop="urn:schemas-microsoft-com:xml-msprop">
> - <xs:element name="NewDataSet" msdata:IsDataSet="true"
> msdata:UseCurrentLocale="true">
> - <xs:complexType>
> - <xs:choice minOccurs="0" maxOccurs="unbounded">
> - <xs:element name="Table">
> - <xs:complexType>
> - <xs:sequence>
>  <xs:element name="COMPANY_NAME" msprop:OraDbType="126"
> type="xs:string" minOccurs="0" />
>  <xs:element name="COMPANY_ADDRESS" msprop:OraDbType="112"
> type="xs:int" minOccurs="0" />
>  <xs:element name="COMPANY_CITY" msprop:OraDbType="112" type="xs:int"
> minOccurs="0" />
>  <xs:element name="COMPANY_ZIP" msprop:OraDbType="112" type="xs:int"
> minOccurs="0" />
>  <xs:element name="COMPANY_COUNTRY" msprop:OraDbType="112"
> type="xs:int" minOccurs="0" />
>  <xs:element name="COMPANY_URL" msprop:OraDbType="126"
> type="xs:string" minOccurs="0" />
>  <xs:element name="COMPANY_PHONE" msprop:OraDbType="126"
> type="xs:string" minOccurs="0" />
>  </xs:sequence>
>  </xs:complexType>
>  </xs:element>
>  </xs:choice>
>  </xs:complexType>
>  </xs:element>
>  </xs:schema>
>
> Everything works fine but the problem is that when I retrieve the data
> and fetch the URL, it gives error (only when a website address URL is
> being fetched). Does anyone has idea what is the cause or/and what is
> the solution?
>
> ERROR MESSAGE: Invalid Property : COMPANY_URL
>
> The Java code:
>
> import java.util.ArrayList;
> import java.util.List;
>
> import org.ksoap2.SoapEnvelope;
> import org.ksoap2.serialization.SoapObject;
> import org.ksoap2.serialization.SoapSerializationEnvelope;
> import org.ksoap2.transport.HttpTransportSE;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.widget.TextView;
>
> public class Companywebservice extends Activity {
>
>        private static final String SOAP_ACTION = "http://tempuri.org/
> FetchCompanyData";
>        private static final String METHOD_NAME = "FetchCompanyData";
>        private static final String NAMESPACE = "http://tempuri.org/";;
>        private static final String URL = "http://example.com/
> service.asmx";
>
>        TextView tv;
>        @Override
>    public void onCreate(Bundle savedInstanceState) {
>        super.onCreate(savedInstanceState);
>        setContentView(R.layout.main);
>
>    tv = (TextView)findViewById(R.id.txtCompName);
>
>    SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
>    Request.addProperty("companyname","MicroCrash");
>    Request.addProperty("country","United States");
>    Request.addProperty("zipcode","");
>
>    SoapSerializationEnvelope SoapEnv = new
> SoapSerializationEnvelope(SoapEnvelope.VER11);
>    SoapEnv.dotNet = true;
>    SoapEnv.setOutputSoapObject(Request);
>
>    HttpTransportSE aht = new HttpTransportSE(URL);
>
>    try
>    {
>        aht.call(SOAP_ACTION, SoapEnv);
>
>        SoapObject resultString = (SoapObject)SoapEnv.getResponse();
>        SoapObject details =
> (SoapObject)resultString.getProperty("diffgram");
>        List<CharSequence> list = new
> ArrayList<CharSequence>(details.getPropertyCount());
>
>        int detailPropertycount = details.getPropertyCount();
>        for (int i = 0; i < detailPropertycount ; i++) {
>            Object property = details.getProperty(i);
>
>            if (property instanceof SoapObject) {
>                SoapObject compdetail = (SoapObject) property;
>                String table =
> compdetail.getProperty("Table").toString();
>
>                int compPropCount = compdetail.getPropertyCount();
>
>                for(int j=0;j<compPropCount;j++)
>                {
>                        Object CompProperties =
> compdetail.getProperty(j);
>
>                        if(CompProperties instanceof SoapObject)
>                        {
>                                SoapObject CompInfo = (SoapObject)
> CompProperties;
>                                String information =
> CompInfo.getProperty("COMPANY_NAME").toString();
>                                String teleinformation =
> CompInfo.getProperty("COMPANY_PHONE").toString();
>                                String urlinformation =
> CompInfo.getProperty("COMPANY_URL").toString();
>
>                                list.add("\nResult:"+j+"\nCompany
> Name:" +
> information
>                                                + "\nTelephone:" +
> Teleinformation
>                                                + "\nWebsite:" +
> urlinformation);
>                        }
>                }
>            }
>        }
>        tv.setText(list.toString());
>
>    }
>    catch(Exception err)
>    {
>        tv.setText("Some error occured!" + err.getMessage());
>    }
>    }}

-- 
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