Solved

WCF External Authentication not working - WSDL Error

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

18 Experts available now in Live!

Get 1:1 Help Now