Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
android webservice
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
yancaidaxia@gmail.com  
View profile  
 More options May 25 2009, 4:53 am
From: "yancaida...@gmail.com" <yancaida...@gmail.com>
Date: Mon, 25 May 2009 01:53:28 -0700 (PDT)
Local: Mon, May 25 2009 4:53 am
Subject: android webservice
Hi,it's my first post and i know it's a good place to share questions
and get answers.I want to make a webservice to read datas from
website.And the first step is to get an String returns by the
site.Here is my code,and i don't know why i can't get the String  str
in which XML contains.
Thank you very much.

package com.yancaidaxia.ExchangeRate;

import java.io.IOException;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ExchangeRate extends Activity {

        private final int WC = LinearLayout.LayoutParams.WRAP_CONTENT;
        private static String str;
        private static final String SERVER_URL="http://www.webxml.com.cn/
WebServices/ExchangeRateWebService.asmx/getExchangeRate?
theType=A";   //the site from which i get datas
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView tv1 = (TextView)findViewById(R.id.welcome);
        TextView tv2 =(TextView)findViewById(R.id.content);
        String temp1 ="";
        try{
                HttpGet request = new HttpGet(SERVER_URL);
                HttpClient client = new DefaultHttpClient();
                HttpResponse httpResponse = client.execute(request);
                temp1 = EntityUtils.toString(httpResponse.getEntity());//xml
datas in string form supposed to be contained in temp1.
                str=temp1;
                Log.e("response", temp1);

        }catch(ClientProtocolException e){
                Log.e("request error",e.getMessage());
        } catch(IOException e){
                Log.e("requset error",e.getMessage());
        }
        tv1.setText(str);//i want to see the xml datas in string form
but nothing is shown.Why?
        tv2.setText("bye");
    }


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Xuan Wu  
View profile  
 More options May 25 2009, 9:10 pm
From: Xuan Wu <yancaida...@gmail.com>
Date: Tue, 26 May 2009 09:10:43 +0800
Local: Mon, May 25 2009 9:10 pm
Subject: Re: android webservice

Is'there any one help me.Thank you.

2009/5/25 yancaida...@gmail.com <yancaida...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Xuan Wu  
View profile  
 More options May 25 2009, 9:23 pm
From: Xuan Wu <yancaida...@gmail.com>
Date: Tue, 26 May 2009 09:23:02 +0800
Local: Mon, May 25 2009 9:23 pm
Subject: Re: android webservice

I know...I have to add a permisson to allow Android to connect to the
Internet in the AndroidManifest.xml.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.yancaidaxia.ExchangeRate"
      android:versionCode="1"
      android:versionName="1.0.0">
      <!-- Permissions -->
      <uses-permission android:name="android.permission.INTERNET"/>
    <application android:icon="@drawable/icon"
android:label="@string/app_name">
        <activity android:name=".ExchangeRate"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Now i get String displayed like
<?xml version="1.0" encoding="utf-8" ?>
*-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<DataSet xmlns="*http://webxml.com.cn/*">
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<xs:schema id="*getExchangeRate*" xmlns="**" xmlns:xs="*
http://www.w3.org/2001/XMLSchema*" xmlns:msdata="*
urn:schemas-microsoft-com:xml-msdata*">
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<xs:element name="*getExchangeRate*"
msdata:IsDataSet="*true*"msdata:UseCurrentLocale
="*true*">
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<xs:complexType>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<xs:choice minOccurs="*0*" maxOccurs="*unbounded*">
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<xs:element name="*ExchangeRate*">
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<xs:complexType>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<xs:sequence>
 * * <xs:element name="*Code*" type="*xs:string*" minOccurs="*0*" />
 * * <xs:element name="*Currency*" type="*xs:string*" minOccurs="*0*" />
 * * <xs:element name="*ClosePrice*" type="*xs:double*" minOccurs="*0*" />
 * * <xs:element name="*DiffPercent*" type="*xs:string*" minOccurs="*0*" />
 * * <xs:element name="*DiffAmount*" type="*xs:double*" minOccurs="*0*" />
 * * <xs:element name="*OpenPrice*" type="*xs:double*" minOccurs="*0*" />
 * * <xs:element name="*HighPrice*" type="*xs:double*" minOccurs="*0*" />
 * * <xs:element name="*LowPrice*" type="*xs:double*" minOccurs="*0*" />
 * * <xs:element name="*Range*" type="*xs:string*" minOccurs="*0*" />
 * * <xs:element name="*BuyPrice*" type="*xs:double*" minOccurs="*0*" />
 * * <xs:element name="*SellPrice*" type="*xs:double*" minOccurs="*0*" />
 * * <xs:element name="*ChangeColor*" type="*xs:string*" minOccurs="*0*" />
 * * <xs:element name="*DataTime*" type="*xs:string*" minOccurs="*0*" />
* * </xs:sequence>
* * </xs:complexType>
* * </xs:element>
* * </xs:choice>
* * </xs:complexType>
* * </xs:element>
* * </xs:schema>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<diffgr:diffgram
xmlns:msdata="*urn:schemas-microsoft-com:xml-msdata*"xmlns:diffgr
="*urn:schemas-microsoft-com:xml-diffgram-v1*">
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<getExchangeRate xmlns="**">
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<ExchangeRate diffgr:id="*ExchangeRate1*" msdata:rowOrder="*0*"diffgr:hasChanges
="*inserted*">
 * * <Code>*JPY*</Code>
 * * <Currency>*日元*</Currency>
 * * <ClosePrice>*94.76*</ClosePrice>
 * * <DiffPercent>*-0.04%*</DiffPercent>
 * * <DiffAmount>*-0.04*</DiffAmount>
 * * <OpenPrice>*94.8*</OpenPrice>
 * * <HighPrice>*95.06*</HighPrice>
 * * <LowPrice>*94.7*</LowPrice>
 * * <Range>*0.38%*</Range>
 * * <BuyPrice>*94.76*</BuyPrice>
 * * <SellPrice>*94.8*</SellPrice>
 * * <ChangeColor>*Green*</ChangeColor>
 * * <DataTime>*09:23:58*</DataTime>
* * </ExchangeRate>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<ExchangeRate diffgr:id="*ExchangeRate2*" msdata:rowOrder="*1*"diffgr:hasChanges
="*inserted*">
 * * <Code>*CHF*</Code>
 * * <Currency>*瑞郎*</Currency>
 * * <ClosePrice>*1.0864*</ClosePrice>
 * * <DiffPercent>*0.32%*</DiffPercent>
 * * <DiffAmount>*0.0035*</DiffAmount>
 * * <OpenPrice>*1.0827*</OpenPrice>
 * * <HighPrice>*1.0869*</HighPrice>
 * * <LowPrice>*1.082*</LowPrice>
 * * <Range>*0.45%*</Range>
 * * <BuyPrice>*1.0864*</BuyPrice>
 * * <SellPrice>*1.0868*</SellPrice>
 * * <ChangeColor>*Red*</ChangeColor>
 * * <DataTime>*09:23:54*</DataTime>
* * </ExchangeRate>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<ExchangeRate diffgr:id="*ExchangeRate3*" msdata:rowOrder="*2*"diffgr:hasChanges
="*inserted*">
 * * <Code>*GBP*</Code>
 * * <Currency>*英镑*</Currency>
 * * <ClosePrice>*1.5875*</ClosePrice>
 * * <DiffPercent>*-0.23%*</DiffPercent>
 * * <DiffAmount>*-0.0037*</DiffAmount>
 * * <OpenPrice>*1.591*</OpenPrice>
 * * <HighPrice>*1.5931*</HighPrice>
 * * <LowPrice>*1.5866*</LowPrice>
 * * <Range>*0.41%*</Range>
 * * <BuyPrice>*1.5875*</BuyPrice>
 * * <SellPrice>*1.5879*</SellPrice>
 * * <ChangeColor>*Green*</ChangeColor>
 * * <DataTime>*09:23:53*</DataTime>
* * </ExchangeRate>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<ExchangeRate diffgr:id="*ExchangeRate4*" msdata:rowOrder="*3*"diffgr:hasChanges
="*inserted*">
 * * <Code>*EUR*</Code>
 * * <Currency>*欧元*</Currency>
 * * <ClosePrice>*1.3965*</ClosePrice>
 * * <DiffPercent>*-0.33%*</DiffPercent>
 * * <DiffAmount>*-0.0046*</DiffAmount>
 * * <OpenPrice>*1.4009*</OpenPrice>
 * * <HighPrice>*1.4021*</HighPrice>
 * * <LowPrice>*1.3962*</LowPrice>
 * * <Range>*0.42%*</Range>
 * * <BuyPrice>*1.3965*</BuyPrice>
 * * <SellPrice>*1.3969*</SellPrice>
 * * <ChangeColor>*Green*</ChangeColor>
 * * <DataTime>*09:23:56*</DataTime>
* * </ExchangeRate>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<ExchangeRate diffgr:id="*ExchangeRate5*" msdata:rowOrder="*4*"diffgr:hasChanges
="*inserted*">
 * * <Code>*HKD*</Code>
 * * <Currency>*港币*</Currency>
 * * <ClosePrice>*7.7512*</ClosePrice>
 * * <DiffPercent>*0.00%*</DiffPercent>
 * * <DiffAmount>*0.0001*</DiffAmount>
 * * <OpenPrice>*7.7513*</OpenPrice>
 * * <HighPrice>*7.7519*</HighPrice>
 * * <LowPrice>*7.7507*</LowPrice>
 * * <Range>*0.02%*</Range>
 * * <BuyPrice>*7.7512*</BuyPrice>
 * * <SellPrice>*7.7516*</SellPrice>
 * * <ChangeColor>*Red*</ChangeColor>
 * * <DataTime>*09:23:41*</DataTime>
* * </ExchangeRate>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<ExchangeRate diffgr:id="*ExchangeRate6*" msdata:rowOrder="*5*"diffgr:hasChanges
="*inserted*">
 * * <Code>*AUD*</Code>
 * * <Currency>*澳元*</Currency>
 * * <ClosePrice>*0.7764*</ClosePrice>
 * * <DiffPercent>*-0.69%*</DiffPercent>
 * * <DiffAmount>*-0.0054*</DiffAmount>
 * * <OpenPrice>*0.7817*</OpenPrice>
 * * <HighPrice>*0.7824*</HighPrice>
 * * <LowPrice>*0.776*</LowPrice>
 * * <Range>*0.82%*</Range>
 * * <BuyPrice>*0.7764*</BuyPrice>
 * * <SellPrice>*0.7768*</SellPrice>
 * * <ChangeColor>*Green*</ChangeColor>
 * * <DataTime>*09:23:56*</DataTime>
* * </ExchangeRate>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<ExchangeRate diffgr:id="*ExchangeRate7*" msdata:rowOrder="*6*"diffgr:hasChanges
="*inserted*">
 * * <Code>*CAD*</Code>
 * * <Currency>*加元*</Currency>
 * * <ClosePrice>*1.1274*</ClosePrice>
 * * <DiffPercent>*0.36%*</DiffPercent>
 * * <DiffAmount>*0.0041*</DiffAmount>
 * * <OpenPrice>*1.1234*</OpenPrice>
 * * <HighPrice>*1.1275*</HighPrice>
 * * <LowPrice>*1.1228*</LowPrice>
 * * <Range>*0.42%*</Range>
 * * <BuyPrice>*1.1274*</BuyPrice>
 * * <SellPrice>*1.1278*</SellPrice>
 * * <ChangeColor>*Red*</ChangeColor>
 * * <DataTime>*09:23:54*</DataTime>
* * </ExchangeRate>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<ExchangeRate diffgr:id="*ExchangeRate8*" msdata:rowOrder="*7*"diffgr:hasChanges
="*inserted*">
 * * <Code>*ERUK*</Code>
 * * <Currency>*欧元英镑*</Currency>
 * * <ClosePrice>*0.8795*</ClosePrice>
 * * <DiffPercent>*-0.09%*</DiffPercent>
 * * <DiffAmount>*-0.0008*</DiffAmount>
 * * <OpenPrice>*0.8804*</OpenPrice>
 * * <HighPrice>*0.8814*</HighPrice>
 * * <LowPrice>*0.8783*</LowPrice>
 * * <Range>*0.35%*</Range>
 * * <BuyPrice>*0.8795*</BuyPrice>
 * * <SellPrice>*0.88*</SellPrice>
 * * <ChangeColor>*Green*</ChangeColor>
 * * <DataTime>*09:23:53*</DataTime>
* * </ExchangeRate>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<ExchangeRate diffgr:id="*ExchangeRate9*" msdata:rowOrder="*8*"diffgr:hasChanges
="*inserted*">
 * * <Code>*ERSF*</Code>
 * * <Currency>*欧元瑞郎*</Currency>
 * * <ClosePrice>*1.5172*</ClosePrice>
 * * <DiffPercent>*0.01%*</DiffPercent>
 * * <DiffAmount>*0.0001*</DiffAmount>
 * * <OpenPrice>*1.5173*</OpenPrice>
 * * <HighPrice>*1.5201*</HighPrice>
 * * <LowPrice>*1.5143*</LowPrice>
 * * <Range>*0.38%*</Range>
 * * <BuyPrice>*1.5172*</BuyPrice>
 * * <SellPrice>*1.5182*</SellPrice>
 * * <ChangeColor>*Red*</ChangeColor>
 * * <DataTime>*09:23:56*</DataTime>
* * </ExchangeRate>
 *-*<http://www.webxml.com.cn/WebServices/ExchangeRateWebService.asmx/getE...>
<ExchangeRate diffgr:id="*ExchangeRate10*"
msdata:rowOrder="*9*"diffgr:hasChanges
="*inserted*">
 * * <Code>*SFYN*</Code>
 * * <Currency>*瑞郎日元*</Currency>
 * * <ClosePrice>*87.1918*</ClosePrice>
 * *
...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »