简体   繁体   中英

Publishing WCF .NET 3.5 to IIS 6 (Windows Server 2003)

I've been developing a WCF web service using .NET 3.5 with IIS7 and it works perfectly on my local computer. I tried publishing it to a server running IIS 6 and even though I can view the WSDL in my browser, the client application doesn't seem to be connecting to it correctly. I launched a packet sniffing app (Charles Proxy) and the response for the first message comes back to the client empty (0 bytes). Every message after the first one times out.

The WCF service is part of a larger application that uses ASP .NET 3.5. That application has been working fine on IIS 6 for awhile now so I think it's something specific to WCF. I also tried throwing an exception in the SVC file to see if it made it that far and the exception never got thrown so I have a feeling it's something more low level that's not working.

Any thoughts? Is there anything I need to install on the IIS5 server? If so how am I still able to view the WSDL in my browser?

The service is being consumed via an SVC file using basicHttpBinding

Here's the meat of the Web.Config (let me know if you need any other part of it):

<system.net>
  <defaultProxy>
    <proxy usesystemdefault="False" proxyaddress="http://127.0.0.1:80" bypassonlocal="True"/>
  </defaultProxy>
</system.net>

...

<system.serviceModel>
  <services>
    <service name="Nexternal.Service.XMLTools.VNService" behaviorConfiguration="VNServiceBehavior">
      <!--The first endpoint would be picked up from the confirg
      this shows how the config can be overriden with the service host-->
      <endpoint address="" binding="basicHttpBinding" contract="Nexternal.Service.XMLTools.IVNService" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" name="mexHttpBinding" />
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="VNServiceBehavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>

I host WCF services in IIS 5.1 and 6 all the time. There is nothing special about it outside of having .Net 3.0+ installed on the server, which I see you have based on the ASP.NET 3.5 comment above.

Are you hosting the service in a .svc file? If you could provide some additional information, I'm sure this issue could be resolved quickly. How are you hosting the WCF Service? What does your endpoint / behaviors look like in your config file? What type of Binding are you using? Remember you can only host http bindings in IIS 6 and lower. Using IIS 7 allow you to use WAS which allow you to use non-http bindings for your services.

Considering that you can see your wsdl, I would say your MEX endpoint is working, but your other Endpoint is not.

The solution could be very easy to difficult. I'm using .net 4.0 and at first it looked impossible to use IIS 6 and Windows Server 2003. After some digging in, I did the following and got it working:

  1. Add .svc exntension mapping into IIS manager. Right click website, home directory tab, click configuration button and add C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_isapi.dll to svc extension.
  2. Un-install updates KB976769v2 and KB980773 from Windows Server 2003.
  3. Remove targetFramework="4.0" from of your web.Config file.
  4. Add serviceHostingEnvironment multipleSiteBindingsEnabled="true" in system.ServiceModel right after the system.ServiceModel tag.
  5. Right click my virtual directory, select ASP.Net tab and select 4.0.30319 or whatever is applicable in respective case.

Chances are, you may have to grant right permissions to NT AUTHORITY/NETWORK SERVICE to access your database(s), if any specified in connection string section of your config file.

WCF在很大程度上依赖于Windows激活服务,我记得在IIS6中启动并运行它是很棘手的(更好的说,相当痛苦),这就是我们最终迁移到IIS7的原因。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM