Click here to Skip to main content
15,887,214 members
Articles / WCF
Tip/Trick

How to replace Machine Name with Domain name in WCF Service wsdl link

Rate me:
Please Sign up or sign in to vote.
4.93/5 (15 votes)
14 Nov 2010CPOL 42.3K   17   4
Today I was developing the application for streaming files on server using WCF. Everything was fine until I deployed application on production server. I found out that WCF was taking machine name instead of IP address or domain name. This accurs when WCF service is hosted on IIS. The links to wsdl use local machine name. The autogenerated page I received when I was navigating to the .svc page said:

svcutil.exe http://[machinename]/FileTransferService.svc


I discovered that it could be done by following steps:


  • Produce the wsdl in the browser and save to file (by hitting .svc?wsdl from browser)
  • Produce the xsd files by hitting url from wsdl (xsd=xsd0, etc), and save to file from browser
  • replace all machine name references from wsdl with domain name (or ip address) and change xsd references and save
  • replace all machine name references from xsd files with domain name (or ip address)
  • make sure to name xsd file with .xsd extension (ie, name0.xsd, name1.xsd, name2.xsd)
  • copy wsdl and xsd file(s) to virtual directory
  • add to your web.config following lines:

XML
<behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehavior">
          <serviceMetadata httpGetEnabled="true" externalMetadataLocation="http://IPorDomainName/MyServices/FileTransferService.wsdl"  />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Marwin Cassovia Soft
Slovakia Slovakia
My name is Robert Kanasz and I have been working with ASP.NET, WinForms and C# for several years.
MCSD - Web Applications
MCSE - Data Platform
MCPD - ASP.NET Developer 3.5
- Web Developer 4
MCITP - Database Administrator 2008
- Database Developer 2008
MCSA - SQL Server 2012
MCTS - .NET Framework 3.5, ASP.NET Applications
- SQL Server 2008, Database Development
- SQL Server 2008, Implementation and Maintenance
- .NET Framework 4, Data Access
- .NET Framework 4, Service Communication Applications
- .NET Framework 4, Web Applications
MS - Programming in HTML5 with JavaScript and CSS3 Specialist

Open source projects: DBScripter - Library for scripting SQL Server database objects


Please, do not forget vote

Comments and Discussions

 
Questioncan't solve my issue Pin
Ye Htut1-Aug-18 21:08
Ye Htut1-Aug-18 21:08 
GeneralReason for my vote of 5 this will come in useful Pin
jim lahey14-Nov-10 21:48
jim lahey14-Nov-10 21:48 
GeneralThanks. It took nearly 2 hours I found the solution for this... Pin
Kanasz Robert13-Nov-10 7:38
professionalKanasz Robert13-Nov-10 7:38 
GeneralReason for my vote of 4 good Pin
chirag.khatsuriya13-Nov-10 7:33
chirag.khatsuriya13-Nov-10 7:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.