我已经从 Outlook 创建了一个控制台电子邮件应用程序阅读应用程序。每当有新消息到达收件箱时,就会调用一个异步方法。此异步方法通过发送 Web 请求调用 Web 服务并执行服务内部的功能。这些应用程序像调度程序作业一样运行。当第一封电子邮件到达收件箱时,这些过程正在工作。第二次出现异常异常:事务范围嵌套错误。当我尝试关闭电子邮件应用程序然后启动时,当时它工作正常。我该如何解决这个异常? 以下是来自电子邮件应用程序的呼叫服务代码
static void Save(string userAlias, string engagementName, string documentTranferId, string fileName, string fileSize,string activityName)
{
try
{
userAlias = userAlias.ToLower();
var url = new StringBuilder();
url.Append(
string.Format("https://myapp.com:8443/Services/MyService/Test.svc/Save?User={0}&Engagement={1}&FileName={2}&DocumentTrasferID={3}&fileSize={4}&ActivityName={5}",userAlias, engagementName, fileName, documentTranferId, fileSize, activityName));
Console.WriteLine(url);
WebRequest request = WebRequest.Create(url.ToString());
CurrentUrl = url.ToString();
var networkCredential = new NetworkCredential("testr", "123Test", "jemi");
request.Credentials = networkCredential;
WebResponse response = request.GetResponse();
Encoding encoding = Encoding.GetEncoding(1252);
var responseStream = new StreamReader(response.GetResponseStream());
string responseResult = responseStream.ReadToEnd();
responseStream.Close();
Console.WriteLine(responseResult);
}
catch(Exception ee)
{
Console.WriteLine(ee.Message);
}
}
服务详情-端点
<OperationContract()> _
<WebGet(UriTemplate:="/Save?User={User}&Engagement={Engagement}&FileName={FileName}&DocumentTrasferID={documentTrasferID}&fileSize={fileSize}&ActivityName={ActivityName}", RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json)> _
Function Save(ByVal User As String, ByVal Engagement As String, ByVal FileName As String, ByVal DocumentTrasferID As String, ByVal fileSize As String, ByVal ActivityName As String) As String
执行
Public Function Save(ByVal User As String, ByVal Engagement As String, ByVal FileName As String, ByVal DocumentTrasferID As String, ByVal fileSize As String, ByVal ActivityName As String) As String Implements IMyInterface.Save
Dim facade= New MyFacade
Dim Result As String = facade.Save(User, Engagement, FileName, DocumentTrasferID, fileSize, ActivityName)
Return Result
End Function
门面类。这是我有异常
Public Function Save(Doc doc,string id,string param) As String
Dim facade= New MyFacade
facade.Save(doc, id, param)
End Function