1

My windows stores app receives a 407 error connecting to my asmx web service. I can browse to the webservice via url fine and invoke it in IE. The webservice works when called from a separate project (signalr hub which is hosted on same iis).

The remote server returned an unexpected response: (407) Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ).

  • The web service reference was created in visual studio by clicking on the references and adding a service reference, I am using the 'serviceReference.SoapClient' way of connecting. This works when not behind a proxy.
  • I am running the windows service from the windows 8 emulator built into visual studio. This is on the same machine that has the web service running in IIS.
  • I have turned on 'Enterprise Authentication' in the app manifest settings.
  • I have added the following to the .asmx web.config.

    <system.net>
        <defaultProxy enabled="true" useDefaultCredentials="true" />
    </system.net>
    
  • I have tried explicitly setting the credentials but it doesn't appear to make a difference:

    proxy.ClientCredentials.Windows.ClientCredential.Domain = "MYDOMAIN";
    proxy.ClientCredentials.Windows.ClientCredential.UserName = "user";
    proxy.ClientCredentials.Windows.ClientCredential.Password = "Password";
    
  • I have only started getting this issue while on a new network trying to setup the app. It worked ok at home - 'worked on my pc' ;)

1 Answer 1

0

I have solved this dilemma by declaring the binding as per the following link: http://blogs.msdn.com/b/wsdevsol/archive/2012/12/21/help-me-how-do-i-connect-to-an-asmx-web-service.aspx

I also turned on 'Private Networks (Client and Server)' as per this stackoverflow post.

Example of my syntax to help anyone else having this issue:

    System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly);
    binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
    System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(new Uri("http://localhost/WebService/myFileName.asmx"));
    MyService.MyServiceSoapClient client = new MyService.MyServiceSoapClient(binding, address);
    MyService.MyMethodResponse response = await client.MyMethodAsync(null);
    var result = response.Body.MyMethodResult;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.