Awesome
NanoKit
A light Web Service client framework targeting Android platform.
##Note NanoKit is initially a fork of nano.
Nano (and related projects: mxjc, mwsc & pico) has been developed by bulldog2011 but stayed as is from 2013. As it is very well designed and implemented, I decided to fork it and upgrade it.
##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.1 release. -
Include the whole source of Nano into your project.
-
Maven reference:
<dependency> <groupId>com.leansoft</groupId> <artifactId>nano-kit</artifactId> <version>0.7.1</version> </dependency> <repository> <id>maxep-releases</id> <url>https://raw.github.com/maxep/mvn-repo/releases</url> </repository>
-
Gradle reference:
dependencies { compile 'com.leansoft:nano-kit:0.7.1' } repositories { maven { url "https://raw.github.com/maxep/mvn-repo/releases" } }
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
XML Schema Data Types | Objective-C Data Types |
---|---|
xsd:base64Binary | byte[] |
xsd:boolean | boolean |
xsd:byte | byte |
xsd:date | java.util.Date |
xsd:dateTime | java.util.Date |
xsd:decimal | java.math.BigDecimal |
xsd:double | double |
xsd:duration | com.leansoft.nano.custom.types.Duration |
xsd:float | float |
xsd:g | java.util.Date |
xsd:hexBinary | byte[] |
xsd:int | int |
xsd:integer | java.lang.BigInteger |
xsd:long | long |
xsd:NOTATION | javax.xml.namespace.QName |
xsd:Qname | javax.xml.namespace.QName |
xsd:short | short |
xsd:string | java.lang.String |
xsd:time | java.util.Date |
xsd:unsignedByte | short |
xsd:unsignedInt | long |
xsd:unsignedShort | int |
Version History
Version | Date | Description |
---|---|---|
0.7.0 | April 14, 2013 | Initial release supporting SOAP/XML Web Service. |
0.7.1 | April 16, 2015 | Upgrade to Android-15 |
##Compatibility NanoKit has been verified with Android 4.0.3(API 15).
##Current Limitation
- Only Document/Literal style Web Service is support, RPC style Web Serivice is not supported.
- SOAP attachment is not supported
License
NanoKit is available under the Apache v2.0 license. See the LICENSE file for more info.