簡體   English   中英

第三方Web服務的WCF包裝器-拋棄[OperationContract(IsOneWay = true)]

[英]WCF wrapper for 3rd party web service - fire and forget [OperationContract(IsOneWay = true)]

我創建了WCF服務,該服務是第三方Web服務的包裝,並添加了一些其他功能。 我的問題是,在我的方法中,我想調用第三方Web服務中的方法,但是我不想等待對這些方法的響應(Web服務非常慢)。 我嘗試在我的方法上使用[OperationContract(IsOneWay = true)],但出現以下錯誤:

System.InvalidOperationException:在方法'MyMethod'上以類型'MyService.MyService'聲明的OperationContractAttribute無效。 OperationContractAttributes僅對以具有ServiceContractAttribute的類型聲明的方法有效。 添加ServiceContractAttribute以鍵入“ MyService.MyService”,或從方法“ MyMethod”中刪除OperationContractAttribute。

在不調用第三方Web服務的方法上使用[OperationContract(IsOneWay = true)]可以正常工作。 有沒有辦法做到這一點?

這是我采用的方法:

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


}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM