Solved

WCF External Authentication not working - WSDL Error

Posted on 2015-02-23
3
262 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTTP Error 401.2 - Unauthorized IIS 7.5 1 117
web services 4 217
Is this correct for working with a web service? 4 152
Common code for classic asp and asp.net 2 72
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 is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now