views:

4503

answers:

3

Hi!

We host a WCF webservice on Windows Server 2003. This server only has 2 internal IP's. We want to expose the service externally. This is done through the firewall that maps an external IP to the service.

So, I would need to modify the service to display that external IP for the internal links. This is not an issue since it should only be used externally.

Changing the Host Header value in IIS gives a 'Bad Request (Invalid Hostname)' response from IIS. I also added an 'address' value to the endpoint entry in the web.config ... but it sill just points to the internal machine name. Any ideas?

edit: I can verify that IIS7 has the exact same behaviour. Address didn't work. Different hostname gave Invalid Hostname error. Is there seriously no way to present a different (fictive) IP? :/

edit2:

<system.serviceModel>
 <bindings>
  <basicHttpBinding>
   <binding name="BasicAnonymous">
    <security mode="None"/>
   </binding>
  </basicHttpBinding>
 </bindings>
 <behaviors>
  <serviceBehaviors>
   <behavior name="Extended">
    <serviceMetadata httpGetEnabled="true"/>
    <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
   </behavior>
  </serviceBehaviors>
 </behaviors>
 <diagnostics>
  <messageLogging logEntireMessage="true" logMalformedMessages="false" logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="true" maxMessagesToLog="3000"/>
 </diagnostics>
 <services>
  <service behaviorConfiguration="Extended" name="AnCWCFWebService.ProductInfoProvider">
   <endpoint address="" binding="basicHttpBinding" name="ASMX" bindingConfiguration="BasicAnonymous" contract="AnCWCFWebService.Interfaces.IProductInfoProvider"/>
  </service>
 </services>
</system.serviceModel>
+4  A: 
EnocNRoll
The 3rd try is the charm, I believe.
EnocNRoll
I didn't try it yet but it looks to me that is the issue. Thx! :) You put a great deal of effort into this hah :D Next time I deploy the service I'll use the trick. I knew IIS was doing something wrong ... so there you have it. Thx again!
SpoBo
I am happy to help. I currently develop WCF services nearly exclusively, so I like to concentrate on understanding all WCF issues as thoroughly as possible. Cheers, I hope it works. I learned a lot by answering this question. Hopefully, other developers will find value in this answer eventually.
EnocNRoll
+1  A: 

You just need to configure your host header in the IIS so that the links in the WSDL references will use the donmain name rather local machine name.

Check out Steps to configure IIS host header so that WCF will use domain name in WSDL references.

codemeit
+1  A: 

Why not just assign a new IP address to the server instead of messing around with hostnames? A Windows Server can have multiple IP addresses for the same NIC.

Here is an article that talks about it.

Darrel Miller
It's not an option. The service has to run inside our network and is supposed to be routed outside of our network into a DMZ. It's all very secure and stuff :/But yeah ... it's what we did now until we find a permanent solution.
SpoBo
Ok. I'll take you word for it but I don't understand why. You can assign an additional IP address within the same internal subnet.
Darrel Miller