1

I have created a WCF service which is a wrapper for a third party web service adding some additional functionality. The issue I have is that within my methods I want to call methods in the 3rd party web service but I don't want to wait for a response (the web service is very slow) on these methods. I have tried using [OperationContract(IsOneWay = true)] on my method but get the following error:

System.InvalidOperationException: The OperationContractAttribute declared on method 'MyMethod' in type 'MyService.MyService'is invalid. OperationContractAttributes are only valid on methods that are declared in a type that has ServiceContractAttribute. Either add ServiceContractAttribute to type 'MyService.MyService' or remove OperationContractAttribute from method 'MyMethod'.

Using [OperationContract(IsOneWay = true)] on methods which don't call the 3rd party web service works fine. Is there a way to do this?

This is the approach I am taking:

public string MyPublicMethod()
{
     //do some stuff

    SomeParams sp = new SomeParams{p1 = "A", P2 = "B"};
    //don't want to wait for this
    MyMethod(sp);

   // do some more stuff

}

[OperationContract(IsOneWay = true)]    
private void MyMethod(SomeParams someParams)
{
     //3rd party service
     WebInterop wisc = new WebInterop();
     var results = (XmlElement)wisc.Search(someParams);

     // do some processing on results


}
4