将WCF服务发布到实时网站
我只玩了大约一周的w/wcf 东西。我让它在 Visual Studio 的开发服务器上运行,现在我想将该项目放到网络上。我在 Visual Studio 中使用发布来通过 ftp 发布它。我的 FTP 客户端确认文件存在,但当我在浏览器中输入地址时,出现以下错误:
“/”应用程序中的服务器错误。 找不到资源。 描述:HTTP 404。您正在查找的资源(或其依赖项之一)可能已被删除、名称已更改或暂时不可用。请检查以下 URL 并确保拼写正确。
请求的 URL:/EquipService.svc
是否需要更改某些设置或需要在服务器上进行某些设置?我不知道为什么它说文件不可用,因为 FileZilla 显示服务器上的文件。任何帮助将不胜感激。 谢谢
编辑: 这是 Web.config,但作为前言,我不知道它在做什么,我只是从另一个人的项目中复制了一些片段,直到错误停止并且它起作用了。 :|
<?xml version="1.0" encoding="UTF-8"?>
<protocolMapping>
<add scheme="http" binding="webHttpBinding" bindingConfiguration="webHttpBinding"/>
</protocolMapping>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="metadataSupport">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<baseAddressPrefixFilters>
<add prefix ="localhost"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<bindings>
<webHttpBinding>
<binding name="webHttpBinding">
<security mode="None">
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="EquipService.svc">
<endpoint address="~/EquipService.svc" binding="webHttpBinding" contract="Equipment.IEquipService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
我仍然不太明白为什么这些服务在 Visual Studio 服务器上运行,而不是在 Web 服务器上运行。
但感谢您的观看。
I have only been playing w/ wcf stuff for about a week. I have it working on the dev server in Visual Studio, and now I want to put the project on the web. I used publish in Visual Studio to put it up w/ ftp. My FTP client confirms the files are there, but when I enter the address in a browser, I get the following error:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /EquipService.svc
Is there some setting I need to change or some setup I need to do on the server? I don't know why it says the file is unavailable since FileZilla shows the files on the server. Any help would be appreciated.
Thanks
EDIT:
Here is the Web.config, but just as a preface, I don't know what any of this is doing, I just copied bits and pieces from another guys project until the errors stopped and it worked. :|
<?xml version="1.0" encoding="UTF-8"?>
<protocolMapping>
<add scheme="http" binding="webHttpBinding" bindingConfiguration="webHttpBinding"/>
</protocolMapping>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="metadataSupport">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<baseAddressPrefixFilters>
<add prefix ="localhost"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<bindings>
<webHttpBinding>
<binding name="webHttpBinding">
<security mode="None">
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="EquipService.svc">
<endpoint address="~/EquipService.svc" binding="webHttpBinding" contract="Equipment.IEquipService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
Im still not quite understanding why the services work on the Visual Studio server, and not on a web server.
But thanks for looking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 WCFTestClient.exe 测试您的服务。
我学到了一些东西。为服务创建一个单独的项目总是好的。
您可以创建一个 Web 服务,并且可以使用 localhost 作为地址在同一个 Web 项目中使用它。
我有一个场景,我尝试使用 javascript 从网站的 HTML 页面调用它,但它不起作用,因为我在常规 Web 应用程序中创建了 Web 服务。为了从 javascript 访问它,我需要通过互联网发布该服务,以便 javascript 可以引用链接(而不是本地主机)。
Use the WCFTestClient.exe to test your service.
Couple of things that I have learned. Its always good to create a seperate project for Services.
You can create a webservice and it can be consumed in the same web project using the localhost as address.
I had a scenario where I was trying to call it from my website's HTML page using javascript and it didn't work because I created the webservice in the regular webapp. In order to access it from javascript i needed to publish that service over the internet so the javascript can refer to a link (rather than localhost).
好吧,我确实设法找出了问题的原因。原来是服务员。由于某种原因,它的物理路径指向了一个不正确的文件夹,现在他们需要修复它。
感谢您的帮助
Well I did manage to find out the cause of the problem. It was the server. For some reason its physical path was pointing to an incorrect folder, and now the ball is in their court to fix it.
Thanks for the help