none
Multipe WCF Web Services(.NET Frame Work 3.5) with WCFSVCHost in IIS 7.5 RRS feed

  • Question

  • Dear All,

    I am newbie in WCF Web Services in IIS 7.5 and looking for the way to host multiple WCF Web Services described below.

    I used only WCF Service Library Template from VS 2008 SP1 IDE

    // IService1.cs
     namespace WCFWebService
     {
          [Service Contract]
          public interface IService1 
          {
               [OperationContract]
               string GetData(int value);
          } 
    } 
    // IService2.cs
     namespace WCFWebService
     {
        [Service Contract]
        public interface IService1 
        {
           [OperationContract]
           int Add(int a, int b);
        } 
    } 
    // Service1.cs
     namespace WCFSWebService
     {
         public class Service1:IService1
         {
                public string GetData(int value)
                {
                      return string.Format("You entered: {0}", value);
                }  
          }  
     }
    //Service2.cs
     namespace WCFSWebService
     {
          public class Service2:IService2
          {
                public string AddData(int a, int b)
                {
                      return a + b; 
                }
           }
    }
      

    However, only one serivice 1 is started in WCFSVCHost and WCFTestClient, I wish to run all services at the same time.

    I hope someone will advise me to close the case(Is it possible to run all web services ?)

    Thanks and best regards


    Thursday, January 10, 2013 3:27 AM

Answers

  • Hi,

    Please make sure you have configured properly in the App.config for the second service.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, January 11, 2013 7:06 AM
    Moderator
  • Hi,

    I managed to solve the issue and the figure u gave me is not clear enough.

    As well I edit and configure serviceBehaviors as show below app.config

    <configuration>
      <system.web>
        <compilation debug="true" />
      </system.web>
        <system.serviceModel>
        <services>
          <service name="WcfServiceLibrary.Service1" behaviorConfiguration="WcfServiceLibrary.Service1Behavior">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary/Service1/" />
              </baseAddresses>
            </host>
            <endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary.IService1">
               <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
    
          <service name="WcfServiceLibrary.Service2" behaviorConfiguration="WcfServiceLibrary.Service2Behavior">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary/Service2/" />
              </baseAddresses>
            </host>
    
            <endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary.IService2">
         
       <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
    
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
          
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="WcfServiceLibrary.Service1Behavior">
              <serviceMetadata httpGetEnabled="True"/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
    
            <behavior name="WcfServiceLibrary.Service2Behavior">
              <serviceMetadata httpGetEnabled="True"/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
            
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>
    
    Thanks and best regards

    • Marked as answer by Mr Ko Ko Friday, January 11, 2013 8:52 AM
    Friday, January 11, 2013 8:51 AM

All replies

  • Hi,

    Please make sure you have configured properly in the App.config for the second service.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, January 11, 2013 7:06 AM
    Moderator
  • Hi,

    The figure u shown me seem like what I want and pls help me how to configure correctly since my task is running out of time.

    Thanks and best regards

    Friday, January 11, 2013 8:24 AM
  • Hi,

    Below is the App.config of test code. For your information.

     <system.serviceModel>
        <services>
          <service name="WcfServiceLibrary1.Service1">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/" />
              </baseAddresses>
            </host>
            <!-- Service Endpoints -->
            <!-- Unless fully qualified, address is relative to base address supplied above -->
            <endpoint address="Service1" binding="basicHttpBinding" contract="WcfServiceLibrary1.IService1">
              <!-- 
                  Upon deployment, the following identity element should be removed or replaced to reflect the 
                  identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
                  automatically.
              -->
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <!-- Metadata Endpoints -->
            <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
            <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
    
          <service name="WcfServiceLibrary1.Service2">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8734/Design_Time_Addresses/WcfServiceLibrary1/" />
              </baseAddresses>
            </host>
            <!-- Service Endpoints -->
            <!-- Unless fully qualified, address is relative to base address supplied above -->
            <endpoint address="Service2" binding="basicHttpBinding" contract="WcfServiceLibrary1.IService2">
              <!-- 
                  Upon deployment, the following identity element should be removed or replaced to reflect the 
                  identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
                  automatically.
              -->
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <!-- Metadata Endpoints -->
            <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
            <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, 
              set the value below to false before deployment -->
              <serviceMetadata httpGetEnabled="True"/>
              <!-- To receive exception details in faults for debugging purposes, 
              set the value below to true.  Set to false before deployment 
              to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, January 11, 2013 8:36 AM
    Moderator
  • Hi,

    I managed to solve the issue and the figure u gave me is not clear enough.

    As well I edit and configure serviceBehaviors as show below app.config

    <configuration>
      <system.web>
        <compilation debug="true" />
      </system.web>
        <system.serviceModel>
        <services>
          <service name="WcfServiceLibrary.Service1" behaviorConfiguration="WcfServiceLibrary.Service1Behavior">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary/Service1/" />
              </baseAddresses>
            </host>
            <endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary.IService1">
               <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
    
          <service name="WcfServiceLibrary.Service2" behaviorConfiguration="WcfServiceLibrary.Service2Behavior">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary/Service2/" />
              </baseAddresses>
            </host>
    
            <endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary.IService2">
         
       <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
    
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
          
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="WcfServiceLibrary.Service1Behavior">
              <serviceMetadata httpGetEnabled="True"/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
    
            <behavior name="WcfServiceLibrary.Service2Behavior">
              <serviceMetadata httpGetEnabled="True"/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
            
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>
    
    Thanks and best regards

    • Marked as answer by Mr Ko Ko Friday, January 11, 2013 8:52 AM
    Friday, January 11, 2013 8:51 AM