From the configuraiton fragment you provided, you actually have two WCF services defined in it and each of them has specify a baseAddress (http scheme) on different port. This will work for self-host case(when you use console or windows forms app...)
However, when hosting in IIS/ASP.NET web application, things are much different. For IIS host, we need to use a .svc file (with the certain ServiceHostFactory specify in it) so that the WCF runtime will activate the WCF service instance based on the .svc
file. And in such case, the base address of the WCF service is also tightly coupled with the .svc file. So if you use HTTP, then the base address is just like:
http://[iis server name]/[webapp name]/service.svc
if you configure it to use https, then the base address will be:
https://[iis server name]/[webapp name]/service.svc
the same applies when you use non-http protocol (via WAS) for WCF service hosted in IIS.
Therefore, if you want to host two WCF services on different HTTP port in IIS, you will need to deploy them under separate site since each IIS site need to have a certain HTTP port bound for its HTTP binding.
You can also get more about the WCF Addressing for IIS hosting at the "IIS Addressing Considerations " within the following article:
gopikrsna
Member
190 Points
234 Posts
Is it possible to expose two base address in IIS
Apr 26, 2012 02:39 PM|LINK
I have a service , which has two base address.
But , when I host in IIS.
Am getting only methods which are in first base address.
this is my config file..
---------------------------
<?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="DataObjects.Properties.Settings.NSpotIntegrationConnectionString" connectionString="Data Source=XXXXXXX;Initial Catalog=NSpotIntegration;User ID=sa;Password=sa@123" providerName="System.Data.SqlClient" /> </connectionStrings> <system.serviceModel> <services> <!--*******************************Purchase Service ***************************--> <service behaviorConfiguration="NSpotSecuredBehaviour" name="WcfSOALibrary.Services.Marketing.NSpotService"> <host> <baseAddresses> <add baseAddress="https://localhost:80/NSpotService" /> </baseAddresses> </host> <endpoint address="" binding="wsHttpBinding" contract="WcfSOALibrary.Services.Marketing.INSpotService" bindingConfiguration="SecureBinding"> <identity> <dns value="localhost"/> </identity> </endpoint> <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> </service> <service behaviorConfiguration="VssplSecuredBehaviour" name="WcfSOALibrary.Services.Marketing.MiddleTierService"> <host> <baseAddresses> <add baseAddress="https://localhost:9006/VasudhaikaService" /> </baseAddresses> </host> <endpoint address="" binding="wsHttpBinding" contract="WcfSOALibrary.Services.Marketing.IMiddleTierService" bindingConfiguration="SecureBinding"> <identity> <dns value="localhost"/> </identity> </endpoint> <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="NSpotSecuredBehaviour"> <serviceMetadata httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> <serviceThrottling maxConcurrentCalls="16" maxConcurrentInstances="2147483647" maxConcurrentSessions="10"/> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> <bufferedReceive maxPendingMessagesPerChannel="2147483647" /> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WcfSOALibrary.Authorize.VasudhaikaAuthorize,WcfSOALibrary"/> </serviceCredentials> </behavior> <behavior name="VssplSecuredBehaviour"> <serviceMetadata httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> <serviceThrottling maxConcurrentCalls="16" maxConcurrentInstances="2147483647" maxConcurrentSessions="10"/> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> <bufferedReceive maxPendingMessagesPerChannel="2147483647" /> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WcfSOALibrary.Authorize.NSpotAuthentication,WcfSOALibrary"/> </serviceCredentials> </behavior> </serviceBehaviors> </behaviors> <bindings> <wsHttpBinding> <binding name="SecureBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:59:00" openTimeout="01:59:00" receiveTimeout="01:59:00" sendTimeout="01:59:00"> <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> <security mode="TransportWithMessageCredential"> <message clientCredentialType="UserName"/> </security> </binding> </wsHttpBinding> </bindings> <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> </system.serviceModel> <system.transactions> <defaultSettings timeout="01:59:00" /> </system.transactions> </configuration>Steven Cheng...
Contributor
4219 Points
548 Posts
Microsoft
Moderator
Re: Is it possible to expose two base address in IIS
Apr 27, 2012 07:17 AM|LINK
Hi gopikrsna,
From the configuraiton fragment you provided, you actually have two WCF services defined in it and each of them has specify a baseAddress (http scheme) on different port. This will work for self-host case(when you use console or windows forms app...)
However, when hosting in IIS/ASP.NET web application, things are much different. For IIS host, we need to use a .svc file (with the certain ServiceHostFactory specify in it) so that the WCF runtime will activate the WCF service instance based on the .svc file. And in such case, the base address of the WCF service is also tightly coupled with the .svc file. So if you use HTTP, then the base address is just like:
http://[iis server name]/[webapp name]/service.svc
if you configure it to use https, then the base address will be:
https://[iis server name]/[webapp name]/service.svc
the same applies when you use non-http protocol (via WAS) for WCF service hosted in IIS.
Therefore, if you want to host two WCF services on different HTTP port in IIS, you will need to deploy them under separate site since each IIS site need to have a certain HTTP port bound for its HTTP binding.
You can also get more about the WCF Addressing for IIS hosting at the "IIS Addressing Considerations " within the following article:
#WCF Addressing In Depth
http://msdn.microsoft.com/en-us/magazine/cc163412.aspx#S3
Feedback to us
Microsoft One Code Framework
gopikrsna
Member
190 Points
234 Posts
Re: Is it possible to expose two base address in IIS
Apr 28, 2012 10:57 AM|LINK
Thanks!!