I have a very simples Hello World WCF Service, that looks like this:
namespace MyWCFServices
{
public class HelloWorldService : IHelloWorldService
{
public String GetMessage()
{
return "Hello world";
}
}
}
namespace MyWCFServices
{
[ServiceContract(Namespace = "http://127.0.0.1:49359/GetMessage/")]
public interface IHelloWorldService
{
[OperationContract]
String GetMessage();
}
}
My web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyWCFServices.HelloWorldService"
behaviorConfiguration="MyServiceTypeBehaviors">
<host>
<baseAddresses>
<add baseAddress="http://127.0.0.1:49359/HostDevServer/HelloWorldService.svc" />
</baseAddresses>
</host>
<endpoint name="GetMessage" address="" binding="basicHttpBinding"
contract="MyWCFServices.IHelloWorldService"/>
<endpoint contract="IMetadataExchange"
binding="mexHttpBinding" address="mex"/>
</service>
</services>
</system.serviceModel>
</configuration>
And my android java:
HttpClient httpClient = new DefaultHttpClient();
String url = "http://10.0.2.2:49359/HostDevServer/HelloWorldService.svc/GetMessage";
//String url = "http://10.0.2.2:49359/HostDevServer/HelloWorldService.svc/GetMessage";
//String url = "http://localhost:49359/HostDevServer/HelloWorldService.svc";
//String url = "http://localhost:49359/GetMessage";
try{
HttpGet method = new HttpGet( new URI(url) );
HttpResponse response = httpClient.execute(method);
if ( response != null )
{
Log.i( "login", "received " + getResponse(response.getEntity()) );
}
else
{
Log.i( "login", "got a null response" );
}
I'm getting the java.net.SocketException: Permission denied. I already have:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
So or my WS is not accepting connections or the android client is connecting in wrong way. Probably both. For those who know, in the android client its needed to place 10.0.2.2 to redirect to a localhost web server, so no problem there (at least it works when connecting to a PHP KSOAP WS locally)
Can anyone please guide me?