?
Solved

WCF External Authentication not working - WSDL Error

Posted on 2015-02-23
3
Medium Priority
?
350 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

840 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