Pages

Showing posts with label released. Show all posts
Showing posts with label released. Show all posts

Wednesday, March 16, 2016

Calling SOAP Web Services with Android APIs

One of the most common functionalities required in mobile applications is to call a web service to retrieve data. This process involves requesting the web service with parameters, receiving the response and parsing it to obtain data.
Today the most common web services types are SOAP and REST. Android does not provide a built in SOAP client, there are many third party libraries that can be used, but well see how to call a SOAP web service with native android APIs.

Requesting SOAP web service:
Before proceeding to the code, lets take a look at the SOAP structure:


a soap request can be something like this:

POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.w3schools.com/GetItems"

<?xml version="1.0"?>
<soap:Envelope

soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header>
<m:Trans
soap_mustUnderstand="1">234
</m:Trans>
</soap:Header>
<soap:Body>
<m:GetPrice >
<m:Item>Apples</m:Item>
</m:GetPrice>
</soap:Body></soap:Envelope>


the SOAP request/response is sent as a SOAP Envelope which consists of a SOAP Header and a SOAP Body.

  1. SOAP Header: optional component of the envelop, contains application specific information, such as authentication.
  2. SOAP Body: the actual message sent to/received from the service.
  3. The header can contain a SOAP Action which identifies the desired function to be called by the service.
Calling the service:
to call the SOAP web service you have to do the following:
First: construct the SOAP envelope manually like this:
String envelope="<?xml version="1.0" encoding="utf-8"?>"+
"<soap:Envelope >"+
"<soap:Body>"+
"<GetItems >"+
"<startDate>%s</ startDate>"+
"<getAll>%s</getAll>"+
"</Items>"+
"</soap:Body>"+
"</soap:Envelope>";

where %s are place holders where you substitute request parameters in like this
String requestEnvelope=String.format(envelope, "10-5-2011","true");


Second: call the web service like this:
String CallWebService(String url,
String soapAction,
String envelope) {
final DefaultHttpClient httpClient=new DefaultHttpClient();
// request parameters
HttpParams params = httpClient.getParams();
HttpConnectionParams.setConnectionTimeout(params, 10000);
HttpConnectionParams.setSoTimeout(params, 15000);
// set parameter
HttpProtocolParams.setUseExpectContinue(httpClient.getParams(), true);

// POST the envelope
HttpPost httppost = new HttpPost(url);
// add headers
httppost.setHeader("soapaction", soapAction);
httppost.setHeader("Content-Type", "text/xml; charset=utf-8");

String responseString="";
try {

// the entity holds the request
HttpEntity entity = new StringEntity(envelope);
httppost.setEntity(entity);

// Response handler
ResponseHandler rh=new ResponseHandler() {
// invoked when client receives response
public String handleResponse(HttpResponse response)
throws ClientProtocolException, IOException {

// get response entity
HttpEntity entity = response.getEntity();

// read the response as byte array
StringBuffer out = new StringBuffer();
byte[] b = EntityUtils.toByteArray(entity);

// write the response byte array to a string buffer
out.append(new String(b, 0, b.length));
return out.toString();
}
};

responseString=httpClient.execute(httppost, rh);

}
catch (Exception e) {
Log.v("exception", e.toString());
}

// close the connection
httpClient.getConnectionManager().shutdown();
return responseString;
}

after calling this function, you will have the response as a String, something like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope >
<soap:Body>
<GetItemsResponse >
<GetItemsResult>

<Items>
<Item>
<name>string</name>
<description>string</ description >
</iPhoneCategory>
<iPhoneCategory>
<name>string</name>
<description>string</ description >
</ Item >
</Items>
</GetItemsResult>
</ GetItemsResponse >
</soap:Body>
</soap:Envelope>


this response needs to be parsed to extract the data.
Read More..

Monday, March 14, 2016

Android Developers Backstage Episode 12 The Jake Show

In a startling and electrifying break with ancient tradition (born of laziness rather than policy), Tor and Chet are joined in this podcast by external developer (i.e., non-Googler) Jake Wharton. Jake has worked on and with many important Android open source libraries. We talk with Jake about these projects and various other aspects of Android development in general.

Subscribe to the podcast feed or download the audio file directly.

Relevant Links:
Retrofit: http://square.github.io/retrofit/
Picasso: http://square.github.io/picasso/
Dagger: http://square.github.io/dagger/
OkHttp: http://square.github.io/okhttp/
Butter Knife: http://jakewharton.github.io/butterknife
Robolectric: http://robolectric.org/
Espresso: https://code.google.com/p/android-test-kit/
AssertJ Android: http://square.github.io/assertj-android

Jake: google.com/+JakeWharton
Tor: google.com/+TorNorbye
Chet: google.com/+ChetHaase

Read More..

Monday, February 29, 2016

Android 2 2 Released

Google released version 2.2 of the Android SDK.
thi version has an API level equals to 8

some of the new features:
  1. Using Dalvik JIT (just in time) compiler which produces faster performance.
  2. the ability to store applications on SD card instead on phone memory as in previous versions.
  3. Application Backup API, enabling to store a backup of any application and use it on other phones.
  4. The browser java script rendering has became faster.
for more info you can check this link http://developer.android.com/sdk/android-2.2.html

or watch this video
Read More..

Friday, February 19, 2016

Android 2 3 Gingerbread released

Yesterday Google fially released the long-anticipated Android 2.3 (Gingerbread).

here are some of the new features:
  1. API Level: 9.
  2. The Dalvik VM introduces a new concurrent garbage collector that produces a smoother and faster performance.
  3. Session Initiation Protocol (SIP) based VoIP API to build telephony applications.
  4. Near Field Communication (NFC) API.
  5. New Sensors: Gyroscope (for measuring orientation), barometer (for measuring atmospheric pressure), sensors for gravity and acceleration.
  6. Support for multiple cameras: the camera API can detect multiple cameras in the device and add new capabilites for shooting such as managing focus.
  7. Usage of third-party video drivers: improves the performance of OpenGL ES.
  8. Audio Effects: new audio effects such as bass boost, reverb and equalization.
  9. New Downlaod Manager: handles downloading files in the background.
  10. Strict Mode: helps developers to optimize their code by detecting disk or network usage that could degrade the performance of the application.
and heres the official release video:
Read More..

Monday, March 10, 2014

App Engine 1 7 7 Released


3 weeks following our last release, the App Engine team is happy to announce 1.7.7.  We plan to deliver our Google I/O release next month.  




Outbound sockets moved to Preview

Outbound sockets is now in preview in this release for Java and Python.  With outbound sockets, billing-enabled App Engine applications can now make outbound connections with TCP or UDP sockets.  This allows developers to build applications that weren’t previously possible on App Engine, such as IMAP or DNS clients.




In the Python runtime, we’ve added support for the Python SSL Library, so you can now open secure connections to remote services such as Apple’s Push Notification service. Similarly, Java developers can now use the javax.net.ssl package to make outbound SSL connections.




Java 7 runtime upgraded to General Availability


The App Engine team is committed to quickly releasing features to General Availability.  You may recall we announced that the Java 7 runtime was in preview just 2 months ago.  Since then we have seen 200% adoption week over week, and today are happy to announce the General Availability of the runtime.  




In order to help developers move over, all app deployments initiated using the new 1.7.7 SDK will use Java 7 unless you explicitly opt out with a command line flag.  In the near future, we plan to automatically update all existing Java 6 applications to Java 7.  Most applications shouldn’t be affected by this change, but we encourage you to start testing your application in advance.  For more compatibility information, we suggest that you check out the Java SE 7 and JDK 7 Compatibility notes.




Google App Engine Maven Plugin


The Google App Engine Maven plugin has been updated to support new goals: now you can directly enhance Datanucleus classes, and generate Google Cloud Endpoints service discovery and client libraries.




Improving the developer experience - goodbye $2.10!


We’re happy to announce that billing-enabled applications will no longer be required to spend a minimum of $2.10 per week. This means that you can enable billing for a free tier application and continue running within the free tier without concern that a spike in traffic will terminate serving (note that you can always specify a daily dollar budget). The minimum spend was originally intended to prevent abuse and ensure that we can offer a stable, reliable system with a free tier.  We have determined that we can continue to support the free tier, without relying on the minimum spend.  So, goodbye $2.10!




Cloud SDK Preview


In our continuing effort to make developers’ lives easier, we are happy to share with you a preview release of the Google Cloud SDK which includes everything from the App Engine SDKs for Java, Python or Go as well as all the tools needed to target Google Compute Engine, Google Cloud SQL, Google Cloud Storage and Google BigQuery in one easy-to-use package.  Please try it out; we are eager to hear your feedback.




A note on reliability improvements


A key benefit of running on a managed service like App Engine is the changes that occur behind the scenes that automatically improve the performance of your applications.  In just the past two months, we’ve made many such improvements:



  • Faster and more consistent deployments.  Many customers are seeing up to 10x reductions in time to deploy a new application version.



  • We have fully deployed an entirely new scheduler system which autoscales applications more smoothly and efficiently.





  • Admin console dashboard charts and current load/error reports have moved to a new, more reliable backend



  • The release version of App Engine is now visible in the Admin Console and in request logs



  • Several stability and scheduling improvements to Task Queue






The complete list of features and bug fixes for 1.7.7 can be found in our release notes. For App Engine coding questions and answers check us out on Stack Overflow, and for general discussion and feedback, find us on our Google Group.






- Posted by Chris Ramsdale, Product Manager









Read More..