tags:

views:

278

answers:

2

I'm protyping an application with WCF and I'm trying to define a Callback Contract with an interface that derives from another one. Doing so, the generated proxy code (using svcutil.exe) does not see the base interface and a "NotSupportedException" is thrown on the Server when trying to call methods defined in base interface.

I have also tried to manually define the base interface in the proxy class so as to be able to implement the methods in the client -> Same behavior.

Does anyone knows why it does not work?

Thanks for any help and sorry for the repost!

Here is my contract definition :

namespace wcfContract
{

[ServiceContract(Namespace = "Test")]
public interface IPing
{
[OperationContract]
void Ping();
}

public interface ITestCallback : IPing       <-------------- IPing method
not seen  at all in proxy
{
[OperationContract]
void TestCB();
}

[ServiceContract(Namespace = "Test", CallbackContract =
typeof(ITestCallback))]
public interface ITest : IPing
{
[OperationContract]
void Test();
}
}
+1  A: 

Did you try adding [ServiceContract] tag to ITestCallback?

TimW
I did -- to no avail.
JasonW
+2  A: 

You'll need to add the [ServiceContract] attribute to the ITestCallback interface.

[ServiceContract]
public interface ITestCallback : IPing
{
    [OperationContract]
    void TestCB ();
}

The service class needs to inherit the derived contract (ie. ITestCallback).

public class Service1 : ITestCallback
{
    ...
}

The corresponding endpoint binding in the Web.config file needs to specify the correct contract (as in the endpoint address for "ws" below).

<services>
  <service name="WcfService.Service1" behaviorConfiguration="WcfService.Service1Behavior">
    <!-- ITestCallback needs to be the contract specified -->
    <endpoint address="ws" binding="wsHttpBinding" contract="WcfService.ITestCallback">
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>

This worked for me; hope it works for you. I didn't use the svcutil, I just referenced by adding a service reference in a project.

Steve Dignan
Thank you very much!
JasonW