new SoapSerializationEnvelope(SoapEnvelope.VER11);
Envelope.bodyOut =
request;
(5)创建HttpTransportsSE 对象。
HttpTransportSE ht=new HttpTransportSE
(“http:// fy.webxml.com.cn/webservices/EnglishChinese.asmx?wsdl”);
(6)使用 call 方法调用 WebService 方法。
ht.call(null,envelope);
(7)使用 getResponse 方法获得 WebService 方法的返回结果并解析返回内容。
SoapObject soapObject =(SoapObject)envelope.getResponse();
6.利用SOAP实现天气服务的解析
(1)具体实现过程:从客户端获取用户输入的城市名称,将城市名称打包成符合SOAP 协议的查询消息,把查询信息发送给提供SOAP 天气服务的服务器 ;服务器内部进行操作之后,返回给客户端查询城市的天气信息,该信息以SOAP 格式返回,客户端对其进行解析之后显示给用户。
(2)具体操作:用户在文本框中输入城市名之后单击“查询”按钮,查询成功后,会在应用界面上显示所查询城市的天气信息。
(3)先编写布局文件中的控件
显示控件,用于显示天气情况 :
<TextView
android:id="@+id/textView1"
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_centerHorizontal=“true”
android:layout_centerVertical=“true”
android:padding="@dimen/padding_medium"
tools:context=".AndroidSoapActivity" />
输入控件,用户输入城市名称:
<Edit