I have a WCF service that is hosted on a remote server using IIS. I want to make this service android compatible so I can consume the service on an android client. The problem I'm having is that I'm trying to use ksoap2 to connect to the service but it's giving me a 400 error every time I try to call the method. I've used fiddler2 to try and see what the problem is and in addition to the 400 error, it's also sending back a content-length: 0 (don't know if that is the cause. Interesting fact, when I specify a content-length in the request on fiddler, it doesn't give me a 400 error but rather doesn't return a response at all) I've already tried changing the binding to a webHttpBinding instead of wsHttpBinding and adding a WebGet attribute above the method with a URITemplate, BodyStyle, etc. but no luck. Here's my code:
Service
public class PublicService : IPublicService
{
public Wallpaper[] GetWallpapers()
{
//return _wallpaperRepository.Items.ToArray();
return new Wallpaper[]{ new Wallpaper()
{
Id = 10
}};
}
}
Interface
[ServiceContract(Namespace = "http://XXXXXXXX.com/ServiceA")]
public interface IPublicService
{
[OperationContract]
Wallpaper[] GetWallpapers();
}
Web.Config
<bindings>
<wsHttpBinding>
<binding name="android"
maxReceivedMessageSize="4097152"
maxBufferPoolSize="4097152">
<readerQuotas
maxStringContentLength="4097152"
maxArrayLength="4097152"
maxBytesPerRead="4097152"
maxNameTableCharCount="4097152"
maxDepth="4097152"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="Service.Concrete.PublicService" behaviorConfiguration="ServiceBehavior">
<endpoint address="PublicService" binding="wsHttpBinding" name="PublicService" contract="Service.Abstract.IPublicService" bindingConfiguration="android"/>
<endpoint binding="mexHttpBinding" bindingConfiguration="" name="mex" contract="IMetadataExchange"/>
</service>
I've been beating my head against the wall for the past several hours and going through countless googling, I'm at a complete lost on what to do next. If anyone has any idea what I'm doing wrong, any advice would be greatly appreciated.