0
votes

I am running into an issue trying to host two services on the same site. They have the same base uri, but different services names, and each has its own contract.

While testing in my VS environment (IIS 7.5) everything works fine. However when I deploy to a server (IIS 8.5), both uri's are showing the same wsdl for some reason. It seems like the contract for the second service is ignored.

There are two different .svc files with code behind. (all names have been changed to protect the innocent.)

sites:

https://mysite/services/Service1.svc

https://mysite/services/Service2.svc

Here is my config:

<services>      
  <service name="Service1" behaviorConfiguration="DefaultBehavior">
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="DefaultBinding" contract="Namespace.IService1"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>        
  </service>
   <service name="Service2" behaviorConfiguration="DefaultBehavior">
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="DefaultBinding" contract="Namespace.IService2"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>        
  </service>
</services> 

<bindings>
    <wsHttpBinding>
        <binding name="DefaultBinding" receiveTimeout="00:05:00" 
                sendTimeout="00:05:00" bypassProxyOnLocal="false" transactionFlow="false" 
                hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" 
                maxReceivedMessageSize="2147483647" messageEncoding="Mtom" 
                textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
              <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              <reliableSession ordered="true" inactivityTimeout="00:5:00" enabled="false"/>
              <security mode="Transport">
                <transport clientCredentialType="None" />
              </security>
        </binding>
    <wsHttpBinding>
<bindings>

<serviceBehaviors>
    <behavior name="DefaultBehavior">
    <serviceMetadata httpsGetEnabled="true"  httpsGetBindingConfiguration="true" />
      <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      <serviceThrottling maxConcurrentCalls="160" maxConcurrentInstances="160" maxConcurrentSessions="100" /> 
    </behavior>
</serviceBehaviors>

The problem is that both sites are reflecting the same WSDL, i.e. same methods for contract="Namespace.IService1" Any ideas on what is going on here to cause this?

3

3 Answers

0
votes

I believe the problem is because they both have the same address. How can the server distinguish if your intent is to call Service1 or Service2?

While keeping the same base URI try to change their address

0
votes

Unfortunately, WCF doesn't really have a good way to handle this use case. You can't have two contracts on the same endpoint

The address for the endpoint for Service1

<endpoint address="" binding="wsHttpBinding" bindingConfiguration="DefaultBinding" contract="Namespace.IService1"/>

The address must be different from that of Service2

    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="DefaultBinding" contract="Namespace.IService2"/>
0
votes

It actually turned out to be something stupid, an xcopy error. My xcopy script for the new additional service was copied and pasted from the original service, but I forgot to rename the .svc source to the new service name. So it copied the same .svc to two different files.