Calling a WCF service from a Metro application – cross machine scenario


So you have developed your WCF service to be consumed by your Metro client application – you would likely have done the development on your local machine. What is the next step [before we move to Azure Smile] ? You will probably take your service and deploy it on another machine either for testing cross machine scenario or you are just going with on-premise hosting.

So what is interesting here? Well, start up the metro client and try to connect to the WCF service. Does it work? 

If you are calling the service asynchronously which is how you should be doing it – you will see the metro client just hang waiting for the service to respond. While calling synchronously you will see an Aggregate exception throw almost instantly with the inner exception being – “There was no endpoint listening at /.svc">/.svc">http://<serverName>/<service>.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.".  with innermost exception of – “{"An attempt was made to access a socket in a way forbidden by its access permissions XXX.XXX.XXX.XXX:80"}”

To fix this – what you need to do is to add an additional capability to your metro application – “Home/Work networking” – this enables metro applications access services in your domain network. More information here.

image

Hope it helps!

Thanks.

Comments (2)

  1. Terrence says:

    I have enabled Home/work networking as well as opened a port in the firewall for the port that the service is listening on, yet my metro app still just hangs.  Anything else you can suggest to do to get accessing a wcf service on the same box working?

    Thanks.

    Terrence

  2. Hi Terrence,

    If the service is deployed on the same machine then you will also need to run checknetisolation.exe tool to give exemption for localhost access – see this post: blogs.msdn.com/…/calling-a-wcf-service-from-a-metro-application.aspx

    Thanks.