码迷,mamicode.com
首页 > 移动开发 > 详细

Android WebService

时间:2015-10-12 14:17:10      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

Web Service简介

Web of Services refers to message-based design frequently found on the Web and in enterprise software. The Web of Services is based on technologies such as HTTP, XML, SOAP, WSDL, SPARQL, and others.

Web Service可以实现将服务器应用通过web开放给其他Web应用或其他平台调用。其实现的方式就是HTTP, XML, SOAP, WSDL等中介。

相关定义

SOAP

SOAP, originally an acronym for Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of web services in computer networks. It uses XML Information Set for its message format, and relies on other application layer protocols, most notably Hypertext Transfer Protocol (HTTP) or Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission.

 

WSDL

 

wsimport -s D:\\MyEclipse2015\\Workspaces\\TheClient\\src -p com.ithaibo.client -keep http://127.0.0.1:8080/Service/ServiceHello?wsdl

 

 

Demo

            // 根据命名空间和方法得到SoapObject对象
            SoapObject soapObject = new SoapObject(targetNameSpace,
                    getSupportProvince);
            // 通过SOAP1.1协议得到envelop对象
            SoapSerializationEnvelope envelop = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            // 将soapObject对象设置为envelop对象,传出消息

            envelop.dotNet = true;
            envelop.setOutputSoapObject(soapObject);
            // 或者envelop.bodyOut = soapObject;
            HttpTransportSE httpSE = new HttpTransportSE(WSDL);
            // 开始调用远程方法
            try {
                httpSE.call(targetNameSpace + getSupportProvince, envelop);
                // 得到远程方法返回的SOAP对象
                SoapObject resultObj = (SoapObject) envelop.getResponse();
                // 得到服务器传回的数据
                int count = resultObj.getPropertyCount();

                …

Android WebService

标签:

原文地址:http://www.cnblogs.com/ithaibo-sit/p/4871368.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!