MSDN > Home page del forum > Windows Communication Foundation > Multiple Services with one implementation class
Formula una domandaFormula una domanda
 

Con rispostaMultiple Services with one implementation class

  • sabato 4 luglio 2009 15.17Etowah_man Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    I have a two service contracts, call them IService1 and IService2 within the same file/namespace.

    I have one implementation class where I am trying to implement both of the services:

    public

     

    class Service1 : IService1, IService2

    {

     

    public string GetData(int value)

    {

     

    return string.Format("You entered: {0}", value);

    }
    ....

    I have added a second address/endpoint to my app.config file:

    <

     

    services>

    <

     

    service name="TestMultipleInterfaces.Service1" behaviorConfiguration="TestMultipleInterfaces.Service1Behavior">

    <

     

    host>

    <

     

    baseAddresses>

    <

     

    add baseAddress = "http://localhost:8731/Design_Time_Addresses/TestMultipleInterfaces/Service1/" />

    </

     

    baseAddresses>

    </

     

    host>

    <!--

     

    Service Endpoints -->

    <!--

     

    Unless fully qualified, address is relative to base address supplied above -->

    <

     

    endpoint address ="Rosey" binding="wsHttpBinding" contract="TestMultipleInterfaces.IService1">

    <

     

    identity>

    <

     

    dns value="localhost"/>

    </

     

    identity>

    </

     

    endpoint>

     

    <

     

    endpoint address ="TestManage" binding="wsHttpBinding" contract="TestMultipleInterfaces.IService2" >

    <

     

    identity>

    <

     

    dns value="localhost"/>

    </

     

    identity>

    </

     

    endpoint>

     

    <

     

    endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

    </

     

    service>

    </

     

    services>

    What happens when I try to run this is that I get an error saying ' Cannot obtain Metadata from
    http://localhost:8731/Design_Time_Addresses/TestMultipleInterfaces/Service1/mex'

    I may be missing something simple here. Does this have to do with the addresses I have given my endpoints?

    Thanks!


    EM

Risposte

Tutte le risposte

  • sabato 4 luglio 2009 20.46Stipe-Ivan Latkovic Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Contiene codice
    When using mex bindings, you have to specify the serviceMetadata attribute. First you have to create a new service behavior:

    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceBehavior">
          <serviceMetadata />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    

    Then you have to assign the behavior to the service using the behaviorConfiguration attribute. 

    Did this help?

    Regards,
    John


  • sabato 4 luglio 2009 21.12Etowah_man Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     

    Actually, that part is already in my config file, I just didn't include it in the above code. The code will work if I remove one of the interfaces and only implement my service class from one of the interfaces. When I add the other one though, thats when I get this error.

    Thanks!


    EM
  • domenica 5 luglio 2009 3.17Stipe-Ivan Latkovic Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Con rispostaContiene codice
    Try adding this to your service's behavior definition:
    <serviceDebug includeExceptionDetailInFaults="True" />
    

    Did it help in localizing the error? 

    Regards,
    John
    • Contrassegnato come rispostaEtowah_man domenica 5 luglio 2009 21.15
    •  
  • domenica 5 luglio 2009 21.15Etowah_man Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    Ah, good tip! Totally forgot about that.

    As I figured, it was something stupid.  I had operation names in my second service that were the same as in my first service, and that conflicted. I fixed it by giving the second service different operation names.

    Thanks!
    EM