locked
Cannot obtain Metadata from http://localhost/myservice RRS feed

  • Question

  • Running Windows 8.1 64 bit with all updates.

    I carried out the instructions found here http://www.brhlavinka.com/2013/06/07/secure-wcf-service-with-basichttpbinding-and-custom-credentials/ just before Programming / Configuring the WCF Client.

    I then carried out the instructions found at http://msdn.microsoft.com/en-us/library/hh556232.aspx and set up my cert. I browse to my service on IIS http://localhost/myService/Service.svc. I get a warning that the cert is not trusted etc but continue and can see the service page.

    I then use the WCF test tool and link to the same service and get the error

    "Microsoft (R) Service Model Metadata Tool
    [Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Attempting to download metadata from 'http://localhost/MyService/service.svc?wsdl' using WS-Metadata Exchange or DISCO.
    Microsoft (R) Service Model Metadata Tool
    [Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Error: Cannot obtain Metadata from http://localhost/myService/Service.svc?wsdl

    If this is a Windows (R) Communication Foundation service to which you have acce
    ss, please check that you have enabled metadata publishing at the specified addr
    ess.  For help enabling metadata publishing, please refer to the MSDN documentat
    ion at http://go.microsoft.com/fwlink/?LinkId=65455.


    WS-Metadata Exchange Error
        URI: http://localhost/myService/Service.svc?wsdl

        Metadata contains a reference that cannot be resolved: 'http://localhost/myService/Service.svc?wsdl'.

    There was no endpoint listening at http://localhost/myService/Service.svc
    ?wsdl that could accept the message. This is often caused by an incorrect addres
    s or SOAP action. See InnerException, if present, for more details.

    The remote server returned an error: (404) Not Found.


    HTTP GET Error
        URI: http://localhost/myService/Service.svc?wsdl

    There was an error downloading 'http://localhost/myService/Service.svc?wsdl'.

    The request failed with HTTP status 404: Not Found.

    If you would like more help, type "svcutil /?"

    "

    My Config file is

    <?xml version="1.0" encoding="UTF-8"?>
    
    <configuration>
    
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
            </listeners>
          </source>
        </sources>
      </system.diagnostics>
      <system.web>
        <compilation debug="false" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" />
      </system.web>
    
      <system.serviceModel>
        <services>
          <service behaviorConfiguration="NewBehavior1" name="Service">
            <endpoint address="" binding="basicHttpBinding" contract="IService" bindingConfiguration="NewBinding1" />
            
          </service>
        </services>
        <bindings>
          <basicHttpBinding>
            <binding name="NewBinding1">
              <security mode="TransportWithMessageCredential" />
            </binding>
          </basicHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior name="NewBehavior1">
              <serviceMetadata httpGetEnabled="true"/>
              <serviceCredentials>
                <userNameAuthentication userNamePasswordValidationMode="Custom"
                  customUserNamePasswordValidatorType="Service, Project.Services" />
              </serviceCredentials>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <directoryBrowse enabled="true" />
      </system.webServer>
    </configuration>

    Can anyone give me some idea on how to resolve this? Ive installed Fiddler and enabled to monitor https traffic but that did nothing.

    Thanks


    • Edited by Pure Deal Wednesday, October 23, 2013 7:00 PM
    Wednesday, October 23, 2013 1:17 PM

All replies

  • Hi,
    As you said that your cert is not trust, maybe you can try to refer to the following to trust a certificate:
    Convince WCF To Trust Self-Signed Certificates:
    http://albao.wordpress.com/2010/09/15/convince-wcf-to-trust-self-signed-certificates/ .

    >>Metadata contains a reference that cannot be resolved: 'http://localhost/myService/Service.svc?wsdl'.

    When occur the above error, please first try to expose a endpoint with the IMetadataExchange contract to your service, this will be as below:

     <endpoint 
              address="mex" 
              binding="mexHttpBinding" 
              contract="IMetadataExchange"/>

    Then if the problem still occurs, maybe 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 metadata needed.

    Best Regards,
    Amy Peng



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 24, 2013 6:23 AM
  • Thanks - i tried the steps in the link you posted but since the service is for a Windows Phone 8 application i couldnt complete the steps (unless you can confirm i missed something/done something wrong).

    I added the end point and that allowed the application connect to the service but when calling a method in the service i keep receiving the error "The remote server returned an error: NotFound." Even though the service worked before i added the certificate.

    To try and narrow down what the problem is i enabled the svc log - ran the app and nothing was listed.

    Im now lost in what i could try next to eliminate the problem or at least try and figure out if what ive done so far is correct or try something to overcome this problem? Appreciate any further help.

    Tuesday, October 29, 2013 9:15 PM
  • Anyone??

    If there is a tutorial I could follow Im more than happy to do that?

    Thursday, October 31, 2013 8:13 AM