Consume Web Services from Metro Apps C# RRS feed

  • Question

  • Hello,

    I am trying my hands on Metro Applications,

    I was trying to consume web service (WCF) and I tried these two codes :

    For this one, i got exception : Unable to connect to remote server. But i m able to see the response when i hit the same url on the browser.

    For this one, i got exception : "An error occurred while sending the request."

    how can i consume a web service in metro app using C#.

    a code sample would be appreciated.

    Thanks in advance.

    Tuesday, April 17, 2012 11:32 AM


All replies

  • There's a HttpClient sample here:  http://code.msdn.microsoft.com/windowsapps/HttpClient-sample-55700664

    Matt Small - Microsoft Escalation Engineer - Forum Moderator

    Tuesday, April 17, 2012 6:42 PM
  • Hi Matt..

    I tried that sample, but didn't help.

    So, i tried consuming soap client using the url "http://wsf.cdyne.com/WeatherWS/Weather.asmx".

    By this way, i m able to get data.

    So, i tried consuming my Web Service:

    But it gives exception while getting response. The exception says: There was no endpoint listening at http://myipaddress/myservice.asmx that could accept the message. This is often caused by an incorrect address or SOAP action.

    InnerException: An attempt was made to access a socket in a way forbidden by its access permissions.

    Also, when i try consuming the same .asmx service (by soap client) from .Net Framework 4.0 Application, it successfully gets the data. But when i try it from VS 2011 beta on Windows 8, it gives the above Exception.

    Is this a problem of .Net Framework Version? or some system settings?

    Please reply..

    • Edited by deepti_M Thursday, April 19, 2012 8:45 AM
    Thursday, April 19, 2012 8:44 AM
  • Do you have "Private Networks (Client & Server)" enabled in the manifest?  Also, if it's a local web service (hosted on same machine), be sure that "Allow Local Network Loopback" is enabled in the project properties.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator

    Friday, April 20, 2012 2:58 PM
  • I had the same problem, it also was the "Private networks (Client & Server)" checkbox. Tahnks a lot :)
    Monday, December 3, 2012 2:44 PM