tags:

views:

198

answers:

3

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>
A: 

WCF relies heavily on Windows Activation Service, and I remember it being tricky (better said, rather painful) to get it up and running in IIS6, which is why we eventually migrated up to IIS7.

thaBadDawg
So is it possible to host WCF in IIS 5 or does it require an upgrade to IIS 7?
Adam
WCF does not rely on WAS at all, it is just a plus. WAS allows one to host non-http WCF services in IIS 7, instead of having to host a TCP service, for example, as a Windows Service using ServiceHost.
CkH
And most of my services end up being net.tcp... and now I am remembering.
thaBadDawg
+2  A: 

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.

CkH
I edited my question to add snippets from the web.config. Also, my coworker mentioned that IIS on the server I was publishing to was upgraded to IIS6 so I was mistaken when I said IIS 5.1. Not sure if that helps. I'm also using an SVC page to expose the service using basicHttpBinding.Thanks for help on this!
Adam
Quick test. You don't need the Mex endpoint if you are exposing an http binding with httpGetEnabled=true. Remove the Mex endpoint and see if you can still hit the WSDL. Also, remove the aspNetCompatibilityEnabled=true line, unless you are requiring aspCompatibilty in the service. What are you using the localhost proxy for, and what happens if you remove it from the config?
CkH
Yup, I just uploaded it without the mex endpoint and the WSDL is coming up fine.
Adam
Just to be clear, did you change the binding to basicHttp or was it hosted in IIS7 this way? You aren't receiving any errors at all? Not even in the EventLog?
CkH
Do you have any special ServiceBehaviors, OperationBehaviors, or attributes on the service? Example: [ServiceContract(SessionMode=SessionMode.Required)], or anything? I'm trying to see if you have any thing that would not be working with you current binding. My bet is that the Eventlog will have some clues for us as to why the service is failing.
CkH
There is one error in the event log but I haven't been able to reproduce it. Its the classic "Object reference not set to an instance of an object" exception but it's not logging that error every time I send a message from the client. To answer your earlier question, I was using basicHttpBinding in IIS7 as well. I am implementing a ServiceBehavior class to handle exceptions so it could be something there. I'll try messing around with that code and see if I get anywhere.
Adam
Could it be "HttpContext.Current.Session"? That worked fine when running locally. Is there another way to reference the session in WCF?
Adam
Got it! It was just a dumb error on my part. It turned out to be the namespace was set to https on the server and it accidentally got changed to http when I entered the new URL into the client after publishing it. The reason I never got an error message was because there was another error in the ServerBehavior which was designed to catch all exceptions and email them to me...unless of course there's an exception thrown in the actual error handler. Ugh. I hate when I make dumb mistakes. Thanks for all your help.
Adam
Glad I could help. Happy Coding
CkH
A: 

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.