Hi, My question is about WCF service I wrote in C#, and android client which consume it using “REST” protocol. I am using example from this link: http://fszlin.blogspot.com/2010/05/comsuming-wcf-services-with-android.html
I am working with Eclipse 3.6 (Android emulator), visual studio 2010 .net framework 4. I wrote a simple WCF service and deployed it to IIS on windows 7 (localhost). I use Android emulator to access the localhost WCF service. I succeed to access the service from android : http://10.0.2.2/WcfAndroid3/VehicleService.svc It returns HTML test page with “200 OK”. But when I try to access the function “GetPlates” in the service (or any other function) I get “HTTP/1.1 400 Bad Request”: http://10.0.2.2/WcfAndroid3/VehicleService.svc/GetPlates This is my function declaration in my interface: [OperationContract] [WebGet( UriTemplate = "/GetPlates", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] IList<string> GetPlates(); This is my web config code: <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <behaviors> <endpointBehaviors> <behavior name="httpBehavior"> <webHttp /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> <services> <service name="HttpWcfWeb.VehicleService"> <endpoint address="" behaviorConfiguration="httpBehavior" binding="webHttpBinding" contract="HttpWcfWeb.IVehicleService" /> </service> </services> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration> And this is a part of my Android client code: HttpGet request = new HttpGet("http://10.0.2.2/WcfAndroid3/ VehicleService.svc/GetPlates"); request.setHeader("Accept", "application/json"); request.setHeader("Content-type", "application/json"); DefaultHttpClient httpClient = new DefaultHttpClient(); HttpResponse response = httpClient.execute(request); Log.i("Test",response.getStatusLine().toString()); Is there any special problem to access a WCF function which is located on IIS localhost (I used 10.0.2.2) from local Android emulator? Is there something wrong with my code? I tried a lot, adding and removing function attributes but I still get the error. I will appreciate any help with this. Thanks in advance! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

