2013-08-01 18 views
1

我創建了一個WCF服務,它是第三方Web服務的包裝,增加了一些附加功能。我遇到的問題是,在我的方法中,我想調用第三方Web服務中的方法,但我不想等待這些方法的響應(Web服務非常慢)。我已經嘗試使用[OperationContract的(IsOneWay =真)]我的方法,但出現以下錯誤:第三方Web服務的WCF包裝 - 消防和遺忘[OperationContract(IsOneWay = true)]

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'.

使用[OperationContract的(IsOneWay =真)]在不調用第三方Web服務工程方法精細。有沒有辦法做到這一點?

這是接近我服用:

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 


} 
+0

你能否提供展示你是如何使調用第三方服務,並與單向等你的代碼的一些示例代碼? – Belogix

+0

我編輯了上面的問題。謝謝 – RedEyedMonster

回答

相關問題