Awesome
##DISCLAIMER
This library is still under construction. Beta testers are more than welcome.
Nano
A light Web Service client framework targeting Android platform
##Feature Highlight
- Support WSDL driven development, code generator tool is provided to auto-genearte strongly typed proxy from WSDL.
- Support SOAP 1.1/1.2 and XML based web service.
- Support automatic SOAP/XML to Java object binding, performance is comparable to Android native XML parser.
- Built on popular and mature loopj async http client library for Android.
- Has been verified with industrial grade Web Service like Amazon ECommerce Web Serivce and eBay Finding/Shopping/Trading Web Service.
- Support asynchronous service invocation, flexible HTTP/SOAP header setting, timeout setting, encoding setting, logging, etc.
- Light-weight, the library jar is less than 150K, no external dependencies on Android platform.
- Besides Web Service, can also be used as a standalone XML and JSON binding framework.
The Big Picture
##How to Use You have a few options:
-
Direct jar reference
Download latest 0.7.0 release -
Include the whole source of Nano into your project
-
Maven reference
<dependency>
<groupId>com.leansoft</groupId>
<artifactId>nano</artifactId>
<version>0.7.0</version>
</dependency>
<repository>
<id>github.release.repo</id>
<url>https://raw.github.com/bulldog2011/bulldog-repo/master/repo/releases/</url>
</repository>
After including Nano into your project, please make sure to add following user permissions in the AndroidManifest.xml
file for network access:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
##WSDL Driven Development Flow
- Generate Java proxy from WSDL
- Create new Android project, add Nano runtime and generated proxy into your project
- Implement appliction logic and UI, call proxy to invoke web service as needed.
##Example Usage After the service proxy is generated from wsdl, service invocation through Nano runtime is extremely simple:
// Get shared client
NumberConversionSoapType_SOAPClient client = NumberConversionServiceClient.getSharedClient();
client.setDebug(true); // enable soap message logging
// build request
NumberToWords request = new NumberToWords();
try {
String number = ((EditText)findViewById(R.id.numerInputText)).getText().toString();
request.ubiNum = new BigInteger(number);
} catch (NumberFormatException ex) {
Toast.makeText(MainActivity.this, "Invalid integer number", Toast.LENGTH_LONG).show();
return;
}
client.numberToWords(request, new SOAPServiceCallback<NumberToWordsResponse>() {
@Override
public void onSuccess(NumberToWordsResponse responseObject) { // success
Toast.makeText(MainActivity.this, responseObject.numberToWordsResult, Toast.LENGTH_LONG).show();
}
@Override
public void onFailure(Throwable error, String errorMessage) { // http or parsing error
Toast.makeText(MainActivity.this, errorMessage, Toast.LENGTH_LONG).show();
}
@Override
public void onSOAPFault(Object soapFault) { // soap fault
Fault fault = (Fault)soapFault;
Toast.makeText(MainActivity.this, fault.faultstring, Toast.LENGTH_LONG).show();
}
});
Web Service Sample List
All samples are in the sample folder, following samples are included:
- NumberConverter - sample using Number Conversion Service SOAP web service from Data Access Worldwide.
- USZipValidator - sample using US Zip Validation Service SOAP Web service from WebServiceMart
- BarCode - Demo app using BarcodeGenerator SOAP web serivce from webserviceX.NET
- HelloAmazonProductAdvertising - Hello world like sample using Amazon Product Advertising API SOAP call.
- HelloeBayFinding - Hello world like sample using eBay Finding API SOAP call.
- HelloeBayShopping - Hello world like sample using eBay Shopping API XML call.
- HelloeBayTrading - Hello world like sample using eBay Trading API SOAP call.
- AmazonBookFinder - Sample Amazon Book search and purchase app using Amazon Product Advertising API.
- eBayDemoApp - Sample eBay Search App using both eBay Finding API and eBay Shopping API.
##Docs for Web Service
- WSDL Driven Development on Android - the Big Picture
- Nano Tutorial 1 - a Number Conversion Sample
- Nano Tutorial 2 - a BarCode Generator Sample
- Nano Tutorial 3 - Hello eBay Finding Service
- Nano Tutorial 4 - Hello eBay Shopping Service
- Nano Tutorial 5 - Hello Amazon Product Advertising API
##Docs for Binding
- Nano Hello World
- Nano List Handling
- Nano Compare to JAXB
- Scheam driven data binding with Nano and mxjc
- Xml Parser and Nano Benchmark on Android
- Nano on Android Tutorial 1
- A full movie search Android application using Nano binding
- Schema Driven Web Serivce Client Development on Android, Part 1 : Hello eBay Finding
- Schema Driven Web Serivce Client Development on Android, Part 2 : eBay Search App
##Mapping between XML Schema Types and Java Types
<table> <tr><th>XML Schema Data Types</th><th>Objective-C Data Types</th></tr> <tr> <td>xsd:base64Binary</td> <td>byte[]</td> </tr> <tr> <td>xsd:boolean</td> <td>boolean</td> </tr> <tr> <td>xsd:byte</td> <td>byte</td> </tr> <tr> <td>xsd:date</td> <td>java.util.Date</td> </tr> <tr> <td>xsd:dateTime</td> <td>java.util.Date</td> </tr> <tr> <td>xsd:decimal</td> <td>java.math.BigDecimal</td> </tr> <tr> <td>xsd:double</td> <td>double</td> </tr> <tr> <td>xsd:duration</td> <td>com.leansoft.nano.custom.types.Duration</td> </tr> <tr> <td>xsd:float</td> <td>float</td> </tr> <tr> <td>xsd:g</td> <td>java.util.Date</td> </tr> <tr> <td>xsd:hexBinary</td> <td>byte[]</td> </tr> <tr> <td>xsd:int</td> <td>int</td> </tr> <tr> <td>xsd:integer</td> <td>java.lang.BigInteger</td> </tr> <tr> <td>xsd:long</td> <td>long</td> </tr> <tr> <td>xsd:NOTATION</td> <td>javax.xml.namespace.QName</td> </tr> <tr> <td>xsd:Qname</td> <td>javax.xml.namespace.QName</td> </tr> <tr> <td>xsd:short</td> <td>short</td> </tr> <tr> <td>xsd:string</td> <td>java.lang.String</td> </tr> <tr> <td>xsd:time</td> <td>java.util.Date</td> </tr> <tr> <td>xsd:unsignedByte</td> <td>short</td> </tr> <tr> <td>xsd:unsignedInt</td> <td>long</td> </tr> <tr> <td>xsd:unsignedShort</td> <td>int</td> </tr> </table>Version History
0.7.0 - April 14, 2013 repository
- Initial release supporting SOAP/XML Web Service.
##Compatibility Nano has been verified with Android 2.2(API 8) and 2.3.6(API 10), Nano should work without problem on Android 2.2 and above although this hasn't been verified formally.
##Current Limitation
- Only Document/Literal style Web Service is support, RPC style Web Serivice is not supported.
- SOAP attachment is not supported
###Copyright and License Copyright 2012 LeanSoft, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.