C# 将.NET Framework应用程序移植到.NET核心请求时缺少响应数据
应用程序正在向不同的端点发送多个请求,所有请求都在.NET Framework中运行良好,但当将其中一个服务移植到核心时,响应并没有包含所有数据,只有部分数据有错误且没有错误 我尝试过对代码进行一些修改,并一直在寻找是否存在异步/同步问题,但我真的不知道该去哪里查找。我希望对于一个有经验的程序员来说,这个问题会在下面的代码中显示出来。如果没有,请让我知道,我会提供一个完整的项目 合同,第一个.NET框架,第二个.NET核心C# 将.NET Framework应用程序移植到.NET核心请求时缺少响应数据,c#,wcf,.net-core,request,wsdl,C#,Wcf,.net Core,Request,Wsdl,应用程序正在向不同的端点发送多个请求,所有请求都在.NET Framework中运行良好,但当将其中一个服务移植到核心时,响应并没有包含所有数据,只有部分数据有错误且没有错误 我尝试过对代码进行一些修改,并一直在寻找是否存在异步/同步问题,但我真的不知道该去哪里查找。我希望对于一个有经验的程序员来说,这个问题会在下面的代码中显示出来。如果没有,请让我知道,我会提供一个完整的项目 合同,第一个.NET框架,第二个.NET核心 public class InskrivningDirekt {
public class InskrivningDirekt
{
public IEnumerable<InskrivningMemberType> GetInskrivningData(string
objektid)
{
InskrivningPortTypeClient client = new InskrivningPortTypeClient();
client.ClientCredentials.UserName.UserName = "";
client.ClientCredentials.UserName.Password = "";
InskrivningRegisterenhetFilterType filter = new
InskrivningRegisterenhetFilterType();
filter.ItemsElementName = new ItemsChoiceType[] {
ItemsChoiceType.objektidentitet };
filter.Items = new string[] { objektid };
GetInskrivningRequestType request = new GetInskrivningRequestType()
{
IncludeData = new InskrivningDatasetType()
{
Items = new bool[] { true },
ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.total }
},
Items = new object[] { filter }
};
return client.GetInskrivning(request).InskrivningMember;
}
}
使用Visual Studio 2019预览ASP.NET Core 3.0生成
[System.Xml.Serialization.XmlArrayAttribute(Order = 9)]
[System.Xml.Serialization.XmlArrayItemAttribute("InskrivetAgande", IsNullable = false)]
public InskrivetAgandeType[] Agande
{
get
{
return this.agandeField;
}
set
{
this.agandeField = value;
}
}
您的错误与身份验证有关吗?不,我也这么认为,但在这种情况下,将是一个错误,根本没有响应。现在,缺少的只是反应的一部分。我添加了两个不同响应的图像。您可能只是指向不同的服务或连接字符串?这两个请求都指向相同的服务。注意:当使用WCF连接到WSDL端点时,我必须使用Visual Studio 2019预览和新的(?)选项来生成同步操作。进度:问题与.Net核心WCF工具生成服务Reference.cs有关。因此,我将.NETFramework中生成的一些类复制/粘贴到Core。这修复了requesttestobjects,但我仍然不知道在这个和其他服务引用中还缺少什么,所以这没有得到解决。
private PropertyInfo GetData(string objektid, string[] categories)
{
PropertyInfo data = new PropertyInfo();
List<Task> tasks = new List<Task>();
tasks.Add(Task.Factory.StartNew(() =>
{
data.Inskrivningsinformation = LMDirectDataModel.GetEnlistmentData(objektid);
}));
Task.Factory.ContinueWhenAll(tasks.ToArray(), results => { }).Wait();
return data;
}
[System.Xml.Serialization.XmlArrayAttribute(Order = 9)]
[System.Xml.Serialization.XmlArrayItemAttribute("Lagfart", typeof(LagfartType))]
[System.Xml.Serialization.XmlArrayItemAttribute("Tomtrattsinnehav", typeof(TomtrattsinnehavType))]
[System.Xml.Serialization.XmlArrayItemAttribute("InskrivetAgande", IsNullable = false)]
public InskrivetAgandeType[] Agande
{
get
{
return this.agandeField;
}
set
{
this.agandeField = value;
this.RaisePropertyChanged("Agande");
}
}
[System.Xml.Serialization.XmlArrayAttribute(Order = 9)]
[System.Xml.Serialization.XmlArrayItemAttribute("InskrivetAgande", IsNullable = false)]
public InskrivetAgandeType[] Agande
{
get
{
return this.agandeField;
}
set
{
this.agandeField = value;
}
}