Solved

WCF External Authentication not working - WSDL Error

Posted on 2015-02-23
3
293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

In previous Articles, we have discussed how we can upload a file using .asmx web service and isolated storage space. Here, in continuation to the topic, I am going to discuss how we can use WCF for the same purpose. Steps: 1.Create the silverli…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

740 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