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 folloving 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
<behaviors> <serviceBehaviors> <behavior name="MyServiceBehavior"> <serviceMetadata httpGetEnabled="true" externalMetadataLocation="http://IPorDomainName/MyServices/FileTransferService.wsdl" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors>
No comments:
Post a Comment