0

I want to send some data from my computer to my phone in my network using WCF & Xamarin. I haven't found any documentation and need some help getting this to work.

Working with WCF in Xamarin did not really help me since it needs an .svc file.

Is it even possible to connect to an application in the local network from xamarin ?

Sorry if the question seems dumb but im really suck here and got no idea how to solve this.

If any1 could just point me to the right direction i'll be very thankful.

EDIT:

So far I managed to get the .svc file from my service using SLsvcUtil.exe.

This is my Service (ServerSide) so far:

System.Net.IPHostEntry entry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());

string ipaddress = entry.AddressList.First(add => add.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToString();


using (ServiceHost host = new ServiceHost(typeof(BusyService)))
{
     ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
     smb.HttpGetEnabled = true;
     smb.HttpGetUrl = new Uri($"http://{ipaddress}:8777/BusyService");
     smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
     host.Description.Behaviors.Add(smb);                

     host.Open();

     Console.WriteLine($"Server started at: {ipaddress}:8777/BusyService");

     Console.ReadLine();
 }

App.config

 <system.serviceModel>        
    <services>
        <service name="ConsoleApplication3.BusyService">
            <endpoint address="http://192.168.56.1:8777/BusyService" binding="basicHttpBinding"
                bindingConfiguration="" name="DefaultEndpoint" contract="ConsoleApplication3.IBusyService" />
        </service>
    </services>
</system.serviceModel>

Right now my AndroiApp is only either throwing a TimeoutEx or EndpointNotFoundEx.

Things I've checked:

  1. AntiMalware is off
  2. Port 8777 is free in Firewall
  3. Server endpoint and client-connnecting-to-endpoint are the same

What can be the issue here ?

Note:

I was getting this Exception earlier but I managed to get rid of it calling _client.OpenAsync() and invocing my methods in _client_OpenCompleted - not sure if this is right ... I've not seen any1 opening the client in the above tutorial...

Felix D.
  • 4,811
  • 8
  • 38
  • 72
  • 1
    yes, you can connect to a locally hosted service, but it will only work when your phone is connected to your local network. Do you already have the WCF service written? This [post](https://stackoverflow.com/questions/9925941/how-do-i-generate-the-svc-file) discusses the purpose of the SVC file in WCF – Jason Jul 06 '17 at 13:25
  • @Jason yes my service is already written. I will check your link. Thanks already! – Felix D. Jul 06 '17 at 15:17
  • @Jason Could you please check my edit, Im really stuck on this... – Felix D. Jul 07 '17 at 16:04
  • are you sure that your device can connect to your local server? Have you verified using the device's browser? Have you checked the server logs to see if it is receiving the connection from the client? Finally, consider using a RESTful service, they are much easier to debug and deal with from a mobile client. – Jason Jul 07 '17 at 16:08
  • @Jason thanks for your hints ! I will check that – Felix D. Jul 07 '17 at 16:09

0 Answers0