Calling a WCF service from a Window 8 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.

 

 

 

posted @ 2012-11-30 15:36  一休上香  阅读(541)  评论(0编辑  收藏  举报