A light Web Service client framework targeting Android platform
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" />
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();
}
});
All samples are in the sample folder, following samples are included:
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 |
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.
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.