Android app won't return result from VB.NET WCF Service

here is my WCF server code (VB.NET)...


Public Class Service1
Implements IService1

Public Sub New()
End Sub

Public Function GetText() As String Implements IService1.GetText
    Return String.Format("YO MTV ROCKS!")
End Function

Public Function GetData(ByVal value As Integer) As String Implements IService1.GetData
    Return String.Format("You entered: {0}", value)
End Function

Public Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType Implements IService1.GetDataUsingDataContract
    If composite Is Nothing Then
        Throw New ArgumentNullException("composite")
    End If
    If composite.BoolValue Then
        composite.StringValue &= "Suffix"
    End If
    Return composite
End Function

End Class


' NOTE: You can use the "Rename" command on the context menu to change the interface 

name "IService1" in both code and config file together.
Public Interface IService1
<OperationContract()> _
<WebGet(UriTemplate:="GetText", BodyStyle:=WebMessageBodyStyle.WrappedRequest, responseformat:=WebMessageFormat.Json, RequestFormat:=WebMessageFormat.Json)> _
Function GetText() As String

<OperationContract()> _
<WebGet(UriTemplate:="GetData?v={value}", responseformat:=WebMessageFormat.Json)> _
Function GetData(ByVal value As Integer) As String

Function GetDataUsingDataContract(ByVal composite As CompositeType) As CompositeType

' TODO: Add your service operations here

End Interface

' Use a data contract as illustrated in the sample below to add composite types to service operations.

Public Class CompositeType

Public Property BoolValue() As Boolean

Public Property StringValue() As String

End Class


<?xml version="1.0"?>

    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
      <customErrors mode="Off"/>
            <behavior name="httpBehavior">
                <webHttp />
            <behavior name="">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
        <service name="HttpWcfWeb.VehicleService">
            <endpoint address=""
                contract="HttpWcfWeb.IVehicleService" />
    <modules runAllManagedModulesForAllRequests="true"/>


here is my android client code...

public static final String _URL = "";
protected void logIn(){


// Send GET request to <service>/GetText
   HttpGet request = new HttpGet(_URL + "/GetText");
   request.setHeader("Accept", "application/json");
   request.setHeader("Content-type", "application/json");

   DefaultHttpClient httpClient = new DefaultHttpClient();
   HttpResponse response = httpClient.execute(request);
   HttpEntity responseEntity = response.getEntity();

   // Read response data into buffer
   long intCount = responseEntity.getContentLength();
     char[] buffer = new char[(int)responseEntity.getContentLength()];
     InputStream stream = responseEntity.getContent();
     InputStreamReader reader = new InputStreamReader(stream);;

     tvStatus.append("response: ");
     JSONArray plates = new JSONArray(new String(buffer));

     for (int i = 0; i < plates.length(); ++i) {

    } catch (Exception e) {

For some unkown reason, I can run the VS 2010 client test and it the WCF host works fine. The code above just returns nothing (it's supposed to return a string)

any ideas on what I'm doing wrong?


I'm not sure about Android (Haven't done any WCF stuff from Android yet) but when I access some of our WCF services from javascript I have to specifically convert the output of the method to JSON before sending it back to javascript or else the JS will get nothing back.

I wonder if this may be the case here? Try returning a properly formatted JSON object?

Need Your Help

Do .NET Environment Variables get deleted

c# .net

I need to store my AWS Access Keys somewhere private, and read via code, not stored in it. I'm thinking on storing them in EnviromentVariabels, but from the description, it makes it unclear if they...

Play MIDI file from Common Lisp

lisp common-lisp midi

Is it possible to play a MIDI file (existing on the hard drive) from Common Lisp? If so, how?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.