Category Archives: Interviewing

Xamarin – Using Web Services

In this lesson will we be discussing how to invoke web services from your Xamarin iOS and Android applications. There are a few different ways that these applications can connect with web service technologies. The Xamarin platform supports consuming different web service technologies, and includes in-built and third-party support for consuming RESTful, ASMX, and Windows Communication Foundation (WCF) services.

What is REST?

Representational State Transfer (REST) is an architectural style for building web services. REST requests are made over HTTP using the same HTTP verbs that web browsers use to retrieve web pages and to send data to servers. The verbs are:

  • GET – this operation is used to retrieve data from the web service.
  • POST – this operation is used to create a new item of data on the web service.
  • PUT – this operation is used to update an item of data on the web service.
  • PATCH – this operation is used to update an item of data on the web service by describing a set of instructions about how the item should be modified. This verb is not used in the sample application.
  • DELETE – this operation is used to delete an item of data on the web service.

Web service APIs that adhere to REST are called RESTful APIs, and are defined using:

  • A base URI.
  • HTTP methods, such as GET, POST, PUT, PATCH, or DELETE.
  • A media type for the data, such as JavaScript Object Notation (JSON).

The simplicity of REST has helped make it the primary method for accessing web services in mobile applications.

What is SOAP?

SOAP (Single Object Access Protocol) is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks. It relies on Extensible Markup Language (XML) for its message format, and usually relies on other Application Layer protocols, most notably Hypertext Transfer Protocol (HTTP) and Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission.

ASP.NET Web Service (ASMX)

ASMX provides the ability to build web services that send messages using the Simple Object Access Protocol (SOAP). SOAP is a platform-independent and language-independent protocol for building and accessing web services. Consumers of an ASMX service do not need to know anything about the platform, object model, or programming language used to implement the service. They only need to understand how to send and receive SOAP messages.

A SOAP message is an XML document containing the following elements:

  • A root element named Envelope that identifies the XML document as a SOAP message.
  • An optional Header element that contains application-specific information such as authentication data. If the Headerelement is present it must be the first child element of the Envelope element.
  • A required Body element that contains the SOAP message intended for the recipient.
  • An optional Fault element that’s used to indicate error messages. If the Fault element is present, it must be a child element of the Body element.

SOAP can operate over many transport protocols, including HTTP, SMTP, TCP, and UDP. However, an ASMX service can only operate over HTTP. The Xamarin platform supports standard SOAP 1.1 implementations over HTTP, and this includes support for many of the standard ASMX service configurations.

Generating a Proxy

proxy must be generated in order to consume an ASMX service, which allows the application to connect to the service. The proxy is constructed by consuming service metadata that defines the methods and associated service configuration. This metadata is exposed as a Web Services Description Language (WSDL) document that is generated by the web service. The proxy is built by using Xamarin Studio or Visual Studio to add a web reference for the web service to the platform-specific projects.

The web service URL can either be a hosted remote source or local file system resource accessible via the file:/// path prefix, for example:


This generates the proxy in the Web or Service References folder of the project. Since a proxy is generated code, it should not be modified.

Windows Communication Foundation (WCF)

WCF is Microsoft’s unified framework for building service-oriented applications. It enables developers to build secure, reliable, transacted, and interoperable distributed applications.

WCF describes a service with a variety of different contracts which include the following:

  • Data contracts – define the data structures that form the basis for the content within a message.
  • Message contracts – compose messages from existing data contracts.
  • Fault contracts – allow custom SOAP faults to be specified.
  • Service contracts – specify the operations that services support and the messages required for interacting with each operation. They also specify any custom fault behavior that can be associated with operations on each service.

There are differences between ASP.NET Web Services (ASMX) and WCF, but it is important to understand that WCF supports the same capabilities that ASMX provides – SOAP messages over HTTP.

In general, the Xamarin platform supports the same client-side subset of WCF that ships with the Silverlight runtime. This includes the most common encoding and protocol implementations of WCF — text-encoded SOAP messages over the HTTP transport protocol using the BasicHttpBinding class. In addition, WCF support requires the use of tools only available in a Windows environment to generate the proxy.

Considerations for web services

When creating apps that require a web service it is important to note that the app will require constant connectivity via the mobile connection or wifi to work. This can cause some problems when users try to use your app in areas of bad connectivity or poor reception. We will look at how to check for both mobile and wifi connectivity in the demo.

In the video below I show you how to connect to a web service using an iOS project but if you are working with Android Xamarin projects, the code and steps are going to be exactly the same. Bonus!

This video will show you how to check for a Wi-Fi and Mobile Internet connections in your Android and iOS applications written with Xamarin.  Once we have checked for network connectivity, I will show you how to connect to a web service using the Windows Communication Foundation (WCF).

Here is the link to the W3Schools web service used in this tutorial –

Xamarin.iOS – Adding Audio

Adding audio to your applications can take on many forms. This could be a sound-effect for a game, audio that is played on demand, or in the form of a podcast or audiobook.

The iOS framework includes support for playing variety of common media types, so that you can easily integrate audio, video and images into your applications. You can play audio or video from media files stored in your application’s resources (raw resources), from standalone files in the filesystem, or from a data stream arriving over a network connection.

Setting Your App Up for Audio

The AVAudioPlayer is used to playback audio data from either memory or a file. Apple recommends using this class to play audio in your app unless you are doing network streaming or require low latency audio I/O.

You can use the AVAudioPlayer to do the following:

  • Play sounds of any duration with optional looping.
  • Play multiple sounds at the same time with optional synchronization.
  • Control volume, playback rate and stereo positioning for each sounds playing.
  • Support features such as fast forward or rewind.
  • Obtain playback level metering data.

AVAudioPlayer supports sounds in any audio format provided by iOS, tvOS and OS X such as .aif, .wav or .mp3.

Starting and Stopping Audio

This video will show you how to use the AVAudioPlayer class to start and stop MP3 audio in your Xamarin iOS app.

Here is the link to the AudioManager class that is used in this video –

Xamarin.Android – Adding Audio

Adding audio to your applications can take on many forms. This could be a sound-effect for a game, audio that is played on demand, or in the form of a podcast or audiobook.

The Android multimedia framework includes support for playing variety of common media types, so that you can easily integrate audio, video and images into your applications. You can play audio or video from media files stored in your application’s resources (raw resources), from standalone files in the filesystem, or from a data stream arriving over a network connection.

Setting Your App Up for Audio

Before starting development on your application using MediaPlayer, make sure your manifest has the appropriate declarations to allow use of related features.

Internet Permission – If you are using MediaPlayer to stream network-based content, your application must request network access.

Wake Lock Permission – If your player application needs to keep the screen from dimming or the processor from sleeping, or uses the MediaPlayer.setScreenOnWhilePlaying() or MediaPlayer.setWakeMode()methods, you must request this permission.

One of the most important components of the media framework is the MediaPlayer class. An object of this class can fetch, decode, and play both audio and video with minimal setup. It supports several different media sources such as:

  • Local resources
  • Internal URIs, such as one you might obtain from a Content Resolver
  • External URLs (streaming)

Playing Audio with MediaPlayer – Using the built-in MediaPlayer class to play audio, including local audio files and streamed audio files with the AudioTrackclass.

Recording Audio – Using the built-in MediaRecorder class to record audio.

Working with Audio Notifications – Using audio notifications to create well-behaved applications that respond correctly to events (such as incoming phone calls) by suspending or canceling their audio outputs.

Working with Low-Level Audio – Playing audio using the AudioTrack class by writing directly to memory buffers. Recording audio using the AudioRecord class and reading directly from memory buffers.

In addition to stopping the MediaPlayer you want to call the release() method on the object when you are done with the audio to free up resources.

Starting and Stopping Audio

This video will show you how to use the MediaPlayer class to start and stop MP3 audio in your Xamarin Android app.

Top 10 Reasons You Won’t Get The Job – Part 2

Picking up with my top 5 from my previous list.

5 – Don’t Lie

It seems like it should be a given but don’t lie on your resume or to your interviewer.  There are plenty of people that are paid to follow up on details and you will be caught out. Not only will you be fired if it finds out that you lied during your interview (or not hired at all).  But you will most likely be blacklisted from applying with that company again in the future, which can deeply hurt your career advancement. There is also the problem with people who work in small circles. One mistake like this and you may find that every HR person in town has heard about what happened at XYZ company, because everyone in HR talks to each other.  Don’t fall into this situation and keep everything on your resume truthful!

4 – You Give Up

When an interviewer gives you a problem to work through during your interview they are looking for a few key things.  First, what is your thought process like when you are faced with a problem?  The best thing you can do in this situation is start talking through the problem aloud, stating your logic and reasoning.  You’re not really talking to the interviewer, just vocalizing your thoughts.  This way the interviewer can hear about what assumptions you are making and possibly jump in with a hint or bit of clarifying information.  We aren’t mind readers so if you’re just staring at the board, stuck and confused, we don’t know what went wrong if you aren’t talking.  The #1 problem that then arises is that you give up on the problem. This is the second thing that your interviewer wants to know about – your character.  What do you do when faced with adversity?  Do you plunge ahead with a potentially wrong answer?  Do you try different angles?  Do you search for resources?  Or do you do the one thing that will ensure they will pass on giving you an offer – you quit working. Even if you are stuck and confused, keep working on the problem from different angles until they stop you.  Never quit.

3 – You Don’t Ask Questions

Every interview article you’ve ever read has probably told you that you need to ask questions during your interview and they all say it because it is true! Asking questions shows that you are interested in the position, want to know more about the company and are excited to work there. Always ask follow up questions during interviews if you want more information on something that the interviewer has discussed. It should not be a one-sided conversation.  Remember that interviews are just as much about you finding a good employer you want to work for as it is about them finding a good fit for their company.  Ask the questions that you need to ask to ensure that you can make an informed decision.  Always have a question ready in your back pocket for the end of the interview when they ask: “Do you have any other questions?”.  Don’t just grab your things and shake their hand.  Show that you are interested by having something to talk about.  I will note a caveat here – avoid bringing up salary, benefits, vacation days or other “sensitive” compensation items that you haven’t discussed yet.  This will make the interviewer a little uncomfortable since they are not prepared to talk about this yet. Keep your questions focused on the day-to-day or responsibilities of the position, things you saw during your tour, technologies, or what the company is currently working on.

2 – You Don’t Apply What You’ve Learned During The Day

This item doesn’t apply to all companies but you could rephrase it to say “You Don’t Apply What You’ve Learned In Past Interviews” and it would work for everyone.  Some companies do multi-part interviews over the course of a day.  You may come in for the first round and if you make the cut, move on to the second round in the same afternoon.  Doing well there may mean a deeper hands-on interview with an engineer a few hours later.  These interviews are very stressful as you have to be on your game all day but they also give you an unparalleled look at the inside of the business. The key thing here is to remember to apply what you are learning as you move through the rounds.  Each interviewer will provide you with feedback or areas for improvement.  If these are things you can change right now, you should be showing that you are listening to feedback and trying to implement and learn from it. Likewise for companies that do a phone interview and then an in-person interview.  If your phone interviewer has given you feedback that you can apply in the in-person interview, be sure you are showing that you are open to feedback and willing to improve.

1 – You Make Assumptions

Don’t assume that you understand what the interviewer is talking about.  Clarify what the interviewer is really asking you so you can be sure that you are answering the question.  I’ve seen interviewees go off on a tangent while working on a problem for 10 minutes only to find that they didn’t understand the problem they were trying to solve. My recommendation is, when you get a whiteboard question, the first thing you should do is write the question on the board. This way, the interviewer can immediately see if you didn’t heard them correctly.  You can also ask them to verify if that is the question they have posed.  Then start with clarifying questions about the problem so you understand what you are solving and are not making assumptions. Write down key information on the board as well.  Once you feel you have a handle on it, start pseudo-coding the problem before you actually code it to work out any logic issues first.

Remember, interviews ultimately want to see you do your best so they can find out if you are the best candidate for the job.  They are not there to intimidate you or make you nervous.  Most will try to help you out if you are providing them with the means to do so.  Relax, try to have fun and learn as much as you can from each interview.  Sometimes it will take a few before you get the job but with each try, you will have more information from which to improve.

Top 10 Reasons You Won’t Get The Job – Part 1

Over the years, I’ve done quite a bit of hiring and the things that people do that negatively impact their chances of getting a job are sometimes pretty astounding. I understand that you are nervous – it’s OK, we’re all human. However, there are some key mistakes that I’ve seen over and over again that I have compiled into my Top 10 Reasons You Won’t Get The Job.  Since these are kind of long, here are the first five:

10 – You Didn’t Prepare

If you have gone through the trouble of finding the job posting, writing a cover letter, submitting all of your documents, and passing a phone interview why would you not prepare for the actual in-person interview?! Before you step into that room you should have done you research on the company.  Find out their mission statement, goals, strategic objectives, position in the industry, and key operating information.  What have been their latest successes? Failures? Find out everything you can about the position.  Use networking tools like LinkedIn and GlassDoor to talk to people that already work there about the job duties, supervisor, and work environment.  You should also find out how this company likes to interview.  Is it going to just be you and a few HR and technical people?  Does this company like to bring in panels of 10? In this age of information there is absolutely no reason to go into these situations blind. There is also no bigger turn off to a hiring manager than to have you ask questions for things that would’ve been easily answered with a small amount of research.  You need to be just as interested in working for the company as you want them to be interested in hiring you.

9 – You Didn’t Sleep

So you spent the night before your interview tossing and turning in bed.  By getting yourself all worked-up and nervous, you have cheated yourself out of the rest that you needed to perform well in your interview and make a good first impression. If you have followed #10 then you should be prepared and feel confident that you can walk into your interview and have the knowledge to succeed.  If you are nervous, it’s OK!  Just take the steps needed to relax and get some sleep.  A hot shower, herbal tea, favorite movie – whatever it takes.

8 – You Show Up Late

You cannot believe the number of people I’ve had show up late to an interview! Not only does this show that you have problems with your organization skills, but it could also means that you now lack the time with your interviewer to demonstrate your skills.  Being late also means that you may become more nervous and flustered.  As if showing up late could ruin a first impression any further than now wasting the interviewer’s time with a poor interview.  Look, those of us on the hiring side of the desk understand that everyone is human.  If you are having a completely hectic day and have been faced with a flat tire, unexpected babysitter problems, or another situation that means you cannot perform at your best – call us before your interview and reschedule.  It is highly unlikely that we’re going to say no.  We want you to show us your best!

7 – You Give One Word Answers

No matter what is going on in your interview, never give one word answers. Even if the question could be answered with a yes or no, find a way to provide more detail or insight.  For example:

Interviewer: I see you worked at XYZ company for 4 years?

You: Yes


Try phrasing things like this:

Interviewer: I see you worked at XYZ company for 4 years?

You: Yes, I started in 2010 and held two job titles during my time there. I primarily worked with ABC technology during my time there.

See the difference? This way you are providing more insight into your skills and giving more conversational answers.

6 – You Lack Details

Like the above, you need to be able to articulate the answers to questions and help the interviewer see why you are the best candidate.  Show your problem solving approach and don’t be afraid to think out loud when given hands-on problems or puzzles. Demonstrate how this job relates to your strengths and connect all of the dots for the interviewer so they can have confidence in choosing you for the job.


This wraps up today’s list.  Check out the final 5