Solved

WCF External Authentication not working - WSDL Error

Posted on 2015-02-23
3
272 Views
Last Modified: 2015-03-03
Hi,

OK, I can view a Webservice within a browser, and the external computer can also do this, however when attempting to add a service reference within Visual Studio, I get the error message:

The document at the url https://xxxxxx.com/ContactUpdate.svc was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
- Report from 'https://aruk.valldata.co.uk/ContactUpdate/ContactUpdate.svc' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
- Report from 'DISCO Document' is 'There was an error downloading 'http://xxxxx.com/ContactUpdate/ContactUpdate.svc?disco'.'.
  - The request failed with HTTP status 400: Bad Request.
- Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
Metadata contains a reference that cannot be resolved: 'https://aruk.valldata.co.uk/ContactUpdate/ContactUpdate.svc'.
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.
The remote server returned an error: (401) Unauthorized.
If the service is defined in the current solution, try building the solution and adding the service reference again.

Open in new window




The current config is:  (please bare in mind some of this has just been randomly inserted due to my own personal ignorance!)

<?xml version="1.0"?>
<configuration>

  <system.web>
    <identity impersonate="true" userName="USER" password="PWD"/>
    <authentication mode="Windows" />
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="ContactUpdate.ContactUpdate">
        <endpoint address=""
            binding="basicHttpBinding"
            contract="ContactUpdate.IContactUpdate">
        </endpoint>
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false"  multipleSiteBindingsEnabled="true">
      <serviceActivations>
        <add service="ContactUpdate.ContactUpdate" relativeAddress="~/ContactUpdate/ContactUpdate.svc"/>
      </serviceActivations>
    </serviceHostingEnvironment>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceAuthorization impersonateCallerForAllOperations="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding>
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows"  proxyCredentialType="None" realm=""/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    
  </system.webServer>
  
</configuration>

Open in new window

0
Comment
Question by:krapvag
  • 2
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40628392
Since you are using Windows authentication, is the web site able to authenticate?  It looks like you are trying to use impersonation with Windows authentication, which makes it seem like you can't authenticate the Windows credentials.

What version of IIS is this site hosted on?
0
 
LVL 1

Accepted Solution

by:
krapvag earned 0 total points
ID: 40631018
Thanks for your comment Bob.  I had to give up in the end and just remove the windows auth and make it anonymous, but restrict it by IP on IIS.  Forgot I posted this question.

As for the config above, it's all bits and pieces of stuff I've probably not understood



Code for anyone who comes across this if they want to do the same solution I did in the end - this is for HTTPS access only:

<system.serviceModel>
    <services>
      <service name="SERVICENAME"
           behaviorConfiguration="metadataSupport">
        <endpoint address=""
                  binding="wsHttpBinding"
                  bindingConfiguration="wsSecureBinding"
                  contract="SERVICE.CONTRACT"/>
        <endpoint address="mex"
                  binding="wsHttpBinding"
                  bindingConfiguration="wsSecureBinding"
                  name="mexHttps"
                  contract="IMetadataExchange" />
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false"  multipleSiteBindingsEnabled="true">
      <serviceActivations>
        <add service="SERVICENAME" relativeAddress="~/SERVICE.SVC"/>
      </serviceActivations>
    </serviceHostingEnvironment>
    <behaviors>
      <endpointBehaviors>
        <behavior name="defaultBehavior"/>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="metadataSupport">
          <serviceMetadata httpsGetEnabled="true" httpsGetUrl=""/>
          <useRequestHeadersForMetadataAddress>
            <defaultPorts>
              <add scheme="https" port="443" />
            </defaultPorts>
          </useRequestHeadersForMetadataAddress>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="wsSecureBinding">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>

Open in new window

0
 
LVL 1

Author Closing Comment

by:krapvag
ID: 40641566
changed my mind on what the solution was
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will show you how to add an attribute to an XML (http://en.wikipedia.org/wiki/XML) stream returned from a Windows Communication Foundation (http://en.wikipedia.org/wiki/Windows_Communication_Foundation) (WCF) Web Service.  Some knowled…
While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question