开发者

Publish WCF service to live website

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"?>

开发者_C百科

<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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜