locked
WCF Service reference to IIS-hosted WCF nightmares RRS feed

  • Question

  • Windows XP SP2, IIS 5.1, Visual Studio 2008, .Net 3.5

     

    I really need help here as I'm at my wits end here.

     

    I have created a test web service and that works. I can access it with the web browser (both from local machine and from remote machine), I can connect to it both with a windows form app and a smart device app but smart device app works and windows form app doesn't (disconnects from web service unexpectedly etc etc).

     

    So I've decided to have a look at WCF instead.

     

    Created a simple WCF service app (from VS2008 new project->vc#->web->wcf service app, build, publish and at first it failed using my LAN IP (10.1.1.250) but then I used http://localhost/WCFService1 and it's ok, it publishes successfully.

     

    I browse to it with my browser at http://localhost/WCFService1 and can see files. Click on Service1.svc and it gives me errors XML format invalid, figured .svc was missing in the WCFService1 app on IIS. Funny but it's defined on "Web Sites" but not on "Default web site" or "WCFService1" app. So added that, now Service1.svc gives me the help page for it, tells me about wsdl, if I click on wsdl it gives me a nice wsdl output page, so everything checks.

     

    I browse to it with my browser from another machine on the LAN and again, everything checks. So it's there.

     

    Now I go back to VS2008 and create a windows forms app. Go to project->add service reference, enter http://localhost/WCFService1 and it bombs out telling me that "An error occurred while attempting to find services at http://localhost/WCFService1/" and Details shows:

     

    ###############################################################################################

    The HTML document does not contain Web service discovery information.
    Metadata contains a reference that cannot be resolved: 'http://localhost/WCFService1/'.
    The remote server returned an unexpected response: (405) Method not allowed.
    The remote server returned an error: (405) Method Not Allowed.
    If the service is defined in the current solution, try building the solution and adding the service reference again.

    ##############################################################################################

     

    The address in address box meanwhile changed to http://localhost/WCFService1/Service1.svc?wsdl

     

    I play smart and click on GO again, this time it takes a minute or so but then again comes back with a different error this time round:

     

    ##################################################################################################

     

    The document at the url http://localhost/WcfService1/Service.svc was not recognized as a known document type.
    The error message from each known type may help you fix the problem:
    - Report from 'DISCO Document' is 'There was an error downloading 'http://biber/WCFService1/Service.svc?disco'.'.
      - The request failed with the error message:
    --
    <?xml version="1.0" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
       <title>Server Unavailable
    </title>
       </head>
       <body>
          <h1><span style="font-family:Verdana;color: #ff3300">Server Application Unavailable
    </span></h1>
          <p>
           <span style="font-family:Verdana;">
            The web application you are attempting to access on this web server is currently unavailable.  Please hit the "Refresh" button in your web browser to retry your request.
    </span></p>
       <p>
       <b>Administrator Note:
    </b> An error message detailing the cause of this specific request failure can be found in the application event log of the web server.  Please review this log entry to discover what caused this error to occur.
     </p>
       </body>
    </html>

    --.
    - Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
    - Report from 'http://localhost/WcfService1/Service.svc' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
    - Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
    Metadata contains a reference that cannot be resolved: 'http://localhost/WcfService1/Service.svc'.
    The underlying connection was closed: The connection was closed unexpectedly.
    The underlying connection was closed: The connection was closed unexpectedly.
    If the service is defined in the current solution, try building the solution and adding the service reference again.

     

    ##############################################################################################

     

     

     

    I try to outsmart it once again by punching in http://localhost/WCFService1/Service1.svc?disco and clicking GO, this time it takes a minute as well but comes back with this error:

     

     

     

    ##############################################################################################

    Metadata contains a reference that cannot be resolved: 'http://biber/WCFService1/Service.svc?wsdl'.
    There was an error downloading 'http://biber/WCFService1/Service.svc?wsdl'.
    The request failed with the error message:
    --
    <?xml version="1.0" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
       <title>Server Unavailable
    </title>
       </head>
       <body>
          <h1><span style="font-family:Verdana;color: #ff3300">Server Application Unavailable
    </span></h1>
          <p>
           <span style="font-family:Verdana;">
            The web application you are attempting to access on this web server is currently unavailable.  Please hit the "Refresh" button in your web browser to retry your request.
    </span></p>
       <p>
       <b>Administrator Note:
    </b> An error message detailing the cause of this specific request failure can be found in the application event log of the web server.  Please review this log entry to discover what caused this error to occur.
     </p>
       </body>
    </html>

    --.
    Metadata contains a reference that cannot be resolved: 'http://localhost/WcfService1/Service.svc?disco'.
    Metadata contains a reference that cannot be resolved: 'http://localhost/WcfService1/Service.svc?disco'.
    If the service is defined in the current solution, try building the solution and adding the service reference again.

    ###############################################################################################

     

    And that's where I start from scratch, delete everything (including the IIS WCF app), re-create the WCF service, re-publish it, try to re-connect to it from a brand new simple app, and fail, and have been doing it for the past two days. I'll start crying soon.

     

    Have I mentioned that I've tried adding and removing things from Web.config? Yes I have. I've also tried changing the way IIS authentication works, from Anonymous disabled, to anonymous enabled with HOST\Administrator, Administrator, HOST\Username, Username, let IIS manage passwords, type in a password, with windows authentication, without windows authentication, practically I've tried everything. Well obviously not everything as it's not working. What else can I try?

     

     

    Basically trying to switch from web services to WCF services turned out to be a config nightmare and I thought it was going to be easy.

     

    YES,  <serviceMetadata httpGetEnabled="true"/> and has allways been that way.

     

    I can post my Web.config if you want but it's basically whatever VS2008 generates by default when you create a WCF service app.

     

     

    Best regards and thanks in advance for your help and input!

     

    Pos

    Sunday, October 5, 2008 9:23 AM

Answers

  • I have solved my problem by (in this order)

     

    Remove IIS

    Install IIS (vanilla install, no messing about with configs, extensions, webs etc)

    Re-Install .net 3.5 SP1

     

     

    Sunday, October 5, 2008 2:29 PM

All replies

  • Did I mention that I've been combing with a fine brush through this forum to find a solution for the past few days but still no luck? I firmly believe that my problems lie within IIS somewhere but can't see it. I did go through that tutorial on enabling your IIS for WFC and deploying WFC to IIS still no luck. And just to remind everything - Web services work, WCF don't. Both Web services and WCF services give me output on the browser, they both give me ?wsdl and ?disco output, just can't add service reference to WCF.

     

    Sunday, October 5, 2008 9:31 AM
  • Also, if I go back to my WCFService project and click on Add service reference from within that project and click on discover it does find the very WCFService on the local dev server (http://localhost:3395/WCFService1/Service.svc) and gives me access to the service. So IIS config problem definitely. Any IIS + WCF experts out there that can guide me through the steps of re-configuring IIS for WCF?

    Sunday, October 5, 2008 9:41 AM
  • I have solved my problem by (in this order)

     

    Remove IIS

    Install IIS (vanilla install, no messing about with configs, extensions, webs etc)

    Re-Install .net 3.5 SP1

     

     

    Sunday, October 5, 2008 2:29 PM
  • i am also facing a similar problem when i host my wcf application on godady. it works perfectly locally, but then when i try to deploy it on godaddy and go to this url : http://myhost.com/myWCFService.svc it gives me the following error.

    XML Parsing Error: no element found 
    Location: http://myhost.com/myWCFService.svc 
    Line Number 1, Column 1: 


    I have the following important configurations in my web.config file.


     <buildProviders> 
            <add extension=".svc" type="System.ServiceModel.Activation.ServiceBuildProvider, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 
     </buildProviders> 


     
    <system.serviceModel> 
        <diagnostics> 
          <messageLogging logMalformedMessages="false" logMessagesAtServiceLevel="false" 
            logMessagesAtTransportLevel="false" /> 
        </diagnostics> 
        <behaviors> 
          <serviceBehaviors> 
            <behavior name="OrderServiceBehavior"
              <serviceMetadata httpGetEnabled="true" /> 
              <serviceDebug includeExceptionDetailInFaults="true" /> 
            </behavior> 
          </serviceBehaviors> 
        </behaviors> 
        <services> 
          <service behaviorConfiguration="myWCFServiceBehavior" name="myWCFService"
            <endpoint address="" binding="wsHttpBinding" contract="ImyWCFService"
              <identity> 
                <dns value="" /> 
              </identity> 
            </endpoint> 
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
          </service> 
        </services> 
      </system.serviceModel> 

    <system.webServer> 
        <validation validateIntegratedModeConfiguration="false"/> 
        <modules> 
          <remove name="ScriptModule"/> 
          <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
        </modules> 
        <handlers> 
          <remove name="WebServiceHandlerFactory-Integrated"/> 
          <remove name="ScriptHandlerFactory"/> 
          <remove name="ScriptHandlerFactoryAppServices"/> 
          <remove name="ScriptResource"/> 
          <remove name="svc"/> 
          <add name="svc" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode" /> 
          <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
          <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
          <add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
        </handlers> 
      </system.webServer> 



    is there anything i am still missing ???

    ShadowMan : The Lord of Dead Side
    Thursday, November 20, 2008 8:33 AM
  • I'm having the same problem as the last poster. Did anyone ever find a solution for this problem?
    Saturday, April 4, 2009 9:41 PM
  • I have the same problem, I hope somebody has the solution.
    Monday, April 6, 2009 5:33 PM
  • I've solved the problem that was giving me the error:

    XML Parsing Error: no element found
    Location: http://myhost.com/myWCFService.svc
    Line Number 1, Column 1:

    I needed to add an httpHandler to my web.config for the svc extension. On all my home computers and my work computer this entry already existed in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config, but apparently it doesn't exist in godaddy's. I added the correct handler and my service came right up.

      <system.web>
        ...
        <httpHandlers>
          <remove verb="*" path="*.svc"/>
          <add path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false"/>
        </httpHandlers>
        ...
      </system.web>
    Monday, April 6, 2009 6:08 PM
  • And I have the same problem with windows form a I get the same problem as yours. Can someone help?
    Saturday, June 27, 2009 9:45 PM
  • @harshil you need to change from wsHttpBinding to basicHttpBinding
    <endpoint address="" binding="wsHttpBinding" contract="ImyWCFService">

    to

    <endpoint address="" binding="basicHttpBinding" contract="ImyWCFService">
    Friday, July 10, 2009 4:06 AM
    • This typically occurs if ASP.NET is not installed or the .svc file type is not mapped to the aspnet_isapi.dll.

      To correct this you must make sure that aspnet_isapi is enabled as a Web service extension for IIS. You can view and modify this setting using IIS Manager, or by running  aspnet_regiis –i –enable   from the .NET Framework installation directory. Once you have done so, verify that ASP.NET is running. To do so, place a test .aspx file in the \inetpub\wwwroot directory, and make sure it can be browsed with a browser. 
    • If you installed IIS after Windows Communication Foundation (WCF) was installed you must run the following command.

      "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r
      This registers the required script maps in IIS.

      You must also make sure that the .svc file type is mapped to aspnet_isapi.dll.
    Ref: http://msdn.microsoft.com/en-us/library/ms752252.aspx
    Wednesday, September 30, 2009 12:33 AM
  • Hi,

    Im also suffering from this problem. I tried some of the suggestions and end up with the error below

          The document was understood, but it could not be processed.
            - The WSDL document contains links that could not be resolved.
            - There was an error downloading 'http://pc-name/TestWCF/MyService.svc?xsd=xsd0'.
            - The request failed with HTTP status 404: Not Found.

     

    Does anyone encountered this? Please reply...

    Thanks alot...

    Wednesday, April 14, 2010 10:30 AM
  • You have to add clientacesspolicy.xml to your project . i had the same issue for a silverlight application,the Ui was working great but the WCF part wasnt working then i researched and added clientaccesspolicy.xml to the project and it worked fine for me then onwards.if you still have issues then try changing the integrated security specification in the web.config with the username and the PWD of your DB. guess that should do the trick 
    Monday, July 19, 2010 10:28 AM
  • The solution to this problem is that IIS needs to have rights to the C:\Windows\Temp folder.  Without this it can't generate the meta data needed.
    • Proposed as answer by VenkyRS Tuesday, February 28, 2012 7:10 PM
    Wednesday, February 22, 2012 2:13 AM
  • The solution to this problem is that IIS needs to have rights to the C:\Windows\Temp folder.  Without this it can't generate the meta data needed.
    This fixed the problem for me. Thanks much for posting this solution!!

    • Edited by VenkyRS Tuesday, February 28, 2012 7:13 PM
    Tuesday, February 28, 2012 7:13 PM