0

I have a Xamarin.Forms PCL application that access webservices via HttpClient. The app is working on Android but on iOS it doesn't connect to the webservices at all. Do I need to create a proxy for iOS and REST?

I have read the information here http://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/ but frankly, it just confused me. I tried to create the proxy, as set out but it didn't work. I will persevere if it is necessary though.

I also tried HttpWebRequest method but wasn't successful with that either.

1 Answer 1

1

You only need to generate a proxy for WCF or SOAP. Rest should work just fine. This is how I implemented a GET to a REST service using HttpClient in a PCL.

using (var client = new HttpClient()) { var result = await client.GetStringAsync(url); return JsonConvert.DeserializeObject<Movie>(result); } 

Of course the other verbs take a little bit more work.

Do you perhaps need a binding redirect in the app.config? Check out this blog post about adding a redirect: http://motzcod.es/post/78863496592/portable-class-libraries-httpclient-so-happy.

Here is an example:

<?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="2.0.5.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.