none
SVCUtil The remote name could not be resolved

    Question

  • Hello,

     

    We have a WCF service that is hosted on IIS. The problem we are facing is that when our clients use svcutil to generate a wsdl it gets the following error:

     

    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://X/virtual-directory/Service.svc?wsdl=wsdl0'.
      - The remote name could not be resolved: 'X'

     

    The server which hosts the service has a name of X. The dns name for the machine is something else (Y). Is there a way to get the wsdl's metadata to use the dns name and not the machine name?

     

    The service's config file is:

    <system.serviceModel>

    <services>

    <service name="Application.Services.Web.External.MisMessageWebService"

    behaviorConfiguration="ServiceBehavior">

    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSSEC_Message"

    contract="Application.Services.Interfaces.IMisMessageService"/>

    </service>

    </services>

    <behaviors>

    <serviceBehaviors>

    <behavior name="ServiceBehavior">

    <serviceMetadata httpGetEnabled="true" httpGetUrl=""/>

    <serviceCredentials>

    <serviceCertificate findValue="AppServer" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />

    <clientCertificate>

    <authentication certificateValidationMode="PeerOrChainTrust" />

    </clientCertificate>

    </serviceCredentials>

    </behavior>

    </serviceBehaviors>

    </behaviors>

    <bindings>

    <wsHttpBinding>

    <binding name="WSSEC_Message">

    <security mode="Message">

    <message clientCredentialType="Certificate" />

    </security>

    </binding>

    </wsHttpBinding>

    </bindings>

    </system.serviceModel>

     

    The error message is:

    Error: Cannot obtain Metadata from http://Y.domain.net/virtual-directory/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://Y.domain.net/virtual-directory/Service.svc?wsdl
     
        Metadata contains a reference that cannot be resolved: 'http://Y.domain.net/virtual-directory/Service.svc?wsdl'.
     
        <?xml version="1.0" encoding="utf-16"?><Fault xmlns="http://www.w3.org/2003/
    05/soap-envelope"><Code><Value>Sender</Value><Subcode><Value xmlns:a="http://sch
    emas.xmlsoap.org/ws/2005/02/sc">a:BadContextToken</Value></Subcode></Code><Reaso
    n><Text xml:lang="en-US">The message could not be processed. This is most likely
     because the action 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get' is inco
    rrect or because the message contains an invalid or expired security context tok
    en or because there is a mismatch between bindings. The security context token w
    ould be invalid if the service aborted the channel due to inactivity. To prevent
     the service from aborting idle sessions prematurely increase the Receive timeou
    t on the service endpoint's binding.</Text></Reason></Fault>
     
     
        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://X/virtual-directory/Service.svc?wsdl=wsdl0'.
      - The remote name could not be resolved: 'X'
     
    We actually have this service installed on our own development server. The server is called Z and the url of the service is http://Z.domain.net/virtual-directory/Service.svc. This works! I.e. if the computer name is also in the url then the wsdl seems to pick it...? (Sorry, I'm just guessing here). The config is the same on both servers.
     
    Any help would be much appreciated.
     
    Thanks
    Sidharth
    Monday, January 21, 2008 10:54 AM

Answers

  • svcutil uses the reference URLs contained in the WSDL returned by your service.   The service cannot see the DNS name and so cannot use it  in it's generated WSDL.  One thing you can do is get the metadata locally on the hosting machine, fix up the URLs, and post those files somewhere.   I don't think you can control the addresses generated duriing metadata generation.   I'll double check though.

    Thursday, January 31, 2008 1:17 AM

All replies

  • svcutil uses the reference URLs contained in the WSDL returned by your service.   The service cannot see the DNS name and so cannot use it  in it's generated WSDL.  One thing you can do is get the metadata locally on the hosting machine, fix up the URLs, and post those files somewhere.   I don't think you can control the addresses generated duriing metadata generation.   I'll double check though.

    Thursday, January 31, 2008 1:17 AM
  • You can't control the host names used in WSDL references so the solution described above is the way to go.

    Thursday, January 31, 2008 2:07 AM
  • Hi Martin,

     

    Thanks for that. We were actually able to fix this by setting the host header to the FQDN.

     

    Regards,

    Sidharth

     

     

    • Proposed as answer by _WhiteRussian Tuesday, May 01, 2012 9:34 PM
    Friday, February 01, 2008 3:18 PM
  • I am facing a problem as well, here is my web.config.

    if you navigate to  https://service.premilance.com/Company.svc page, notice that the text says

    svcutil.exe https://pserver/Company.svc?wsdl

    but the problme is i'm not using intranet or access locally.

    I've tried many ways to see if that "pserver" could be replaced with the following baseAddress,
    but it's not working at all. can you help me?

    i am hosting under win 2003, iis 6.0 thx.


        <system.serviceModel>
            <services>
                <service behaviorConfiguration="ServiceBehavior" name="CF.BL.Company">
                    <endpoint address="/Company" binding="wsHttpBinding" bindingConfiguration="WSHttpBindingConfig"
                      name="CompanyEndpoint" contract="CF.Interface.ICompany">
                    </endpoint>
                    <host>
                        <baseAddresses>
                            <add baseAddress="https://service.premilance.com/Company.svc"/>
                        </baseAddresses>
                    </host>
                </service>
            </services>
            <bindings>
                <wsHttpBinding>
                    <binding name="WSHttpBindingConfig">
                        <security mode="TransportWithMessageCredential">
                            <transport clientCredentialType="None" />
                            <message clientCredentialType="UserName" />
                        </security>
                    </binding>
                </wsHttpBinding>
            </bindings>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="ServiceBehavior">
                        <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
                        <serviceDebug includeExceptionDetailInFaults="true" />
                    </behavior>
                </serviceBehaviors>
            </behaviors>
        </system.serviceModel>
    Thursday, May 01, 2008 4:48 AM
  • Hi,

     

    I don't know if this is right (as the SysAdmin fixed my problem) but try setting the host headers in IIS.

     

    IIS > Web site Properties > Web Site tab > Advanced > Set the host header name (to service.premilance.com)

     

    There might be somewhere else that you have to set to get it to work, if I find out I'll let you know but you may as well try the above.

     

    Thanks

    Sidharth

    • Proposed as answer by pdschuller_ Wednesday, December 07, 2011 3:45 PM
    Thursday, May 01, 2008 11:27 AM
  •  

    The following blog talks about this in Details - http://blogs.msdn.com/wenlong/archive/2007/08/02/how-to-change-hostname-in-wsdl-of-an-iis-hosted-service.aspx

     

    I think for aznkk77  it didnt work because he was configuring a binding over HTTP where as the actual service is hosted over HTTPS. For https you need to configure the SecureBindings  and this has to be done by running the adsutil.vbs command only because the option of configuring the hostname for SSL doesnt exist in the IIS UI.

    Friday, August 22, 2008 10:33 AM
  • Thank you SidharthNayyar! I knew it was something simple and brilliant. See (http://technet.microsoft.com/en-us/library/cc753195(v=ws.10).aspx)
    Tuesday, May 01, 2012 9:35 PM