Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid app won't return result from VB.NET WCF Service
    primarykey
    data
    text
    <p>here is my WCF server code (VB.NET)...</p> <p><strong>Service1.svc</strong></p> <pre><code>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 &amp;= "Suffix" End If Return composite End Function End Class </code></pre> <p><strong>IService1.vb</strong></p> <pre><code>' NOTE: You can use the "Rename" command on the context menu to change the interface name "IService1" in both code and config file together. &lt;ServiceContract()&gt; Public Interface IService1 &lt;OperationContract()&gt; _ &lt;WebGet(UriTemplate:="GetText", BodyStyle:=WebMessageBodyStyle.WrappedRequest, responseformat:=WebMessageFormat.Json, RequestFormat:=WebMessageFormat.Json)&gt; _ Function GetText() As String &lt;OperationContract()&gt; _ &lt;WebGet(UriTemplate:="GetData?v={value}", responseformat:=WebMessageFormat.Json)&gt; _ Function GetData(ByVal value As Integer) As String &lt;OperationContract()&gt; 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. &lt;DataContract()&gt; Public Class CompositeType &lt;DataMember()&gt; Public Property BoolValue() As Boolean &lt;DataMember()&gt; Public Property StringValue() As String </code></pre> <p>End Class</p> <p><strong>Web.config</strong></p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;configuration&gt; &lt;system.web&gt; &lt;compilation debug="true" strict="false" explicit="true" targetFramework="4.0" /&gt; &lt;customErrors mode="Off"/&gt; &lt;/system.web&gt; &lt;system.serviceModel&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="httpBehavior"&gt; &lt;webHttp /&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name=""&gt; &lt;serviceMetadata httpGetEnabled="true" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt; &lt;services&gt; &lt;service name="HttpWcfWeb.VehicleService"&gt; &lt;endpoint address="" behaviorConfiguration="httpBehavior" binding="webHttpBinding" contract="HttpWcfWeb.IVehicleService" /&gt; &lt;/service&gt; &lt;/services&gt; &lt;/system.serviceModel&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"/&gt; &lt;/system.webServer&gt; &lt;/configuration&gt; </code></pre> <p>here is my android client code...</p> <pre><code>public static final String _URL = "http://192.168.212.37:8080/Service1.svc"; protected void logIn(){ try { // Send GET request to &lt;service&gt;/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); reader.read(buffer); stream.close(); tvStatus.append("response: "); JSONArray plates = new JSONArray(new String(buffer)); for (int i = 0; i &lt; plates.length(); ++i) { tvStatus.append(plates.getString(i)); } } catch (Exception e) { e.printStackTrace(); } } </code></pre> <p>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)</p> <p>any ideas on what I'm doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload