.NET Core 2.2:如何将 WSDL 用于 WCF 参考
.NET Core 2.2 : How to use WSDL for WCF reference
我有一个(似乎)旧的 ASMX 服务,需要将它用于 .NET Core 2.2。
首先,当我尝试将其添加为 WCF 服务时,我在尝试使用时遇到错误:
InvalidOperationException: The top XML element 'data' from namespace '' references distinct types ServiceReference1.WSIssueNewPayrollCardData and ServiceReference1.WSIssueNewPersonalizedPayrollCardData. Use XML attributes to specify another XML name or namespace for the element or types.
System.Xml.Serialization.XmlReflectionImporter.ReconcileAccessor(Accessor accessor, NameTable accessors)
InvalidOperationException: There was an error reflecting 'data'.
System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, string ns, bool hasWrapperElement, bool rpc, bool openModel, RecursionLimiter limiter)
好的,转到 WSIssueNewPayrollCardData
的定义并为每个 public 属性 添加命名空间,它已经具有相同的名称:
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://com.tch.cards.service/types")]
public partial class WSIssueNewPayrollCardData
{
private string shipToFirstField;
private string shipToLastField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0, Namespace = "http://com.tch.cards.service/types/WSIssueNewPayrollCardData")]
public string shipToFirst
{
get
{
return this.shipToFirstField;
}
set
{
this.shipToFirstField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1, Namespace = "http://com.tch.cards.service/types/WSIssueNewPayrollCardData")]
public string shipToLast
{
get
{
return this.shipToLastField;
}
set
{
this.shipToLastField = value;
}
}
/// <remarks/>
}
那就开始吧。
但是我面对另一个问题:
InvalidOperationException: The Form property may not be 'Unqualified'
when an explicit Namespace property is present.
System.Xml.Serialization.XmlReflectionImporter.CheckForm(XmlSchemaForm
form, bool isQualified)
InvalidOperationException: There was an error reflecting property
'shipToFirst'.
System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping
mapping, StructModel model, bool openModel, string typeName,
RecursionLimiter limiter)
InvalidOperationException: There was an error reflecting type
'ServiceReference1.WSIssueNewPayrollCardData'.
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel
model, string ns, ImportContext context, string dataType,
XmlAttributes a, bool repeats, bool openModel, RecursionLimiter
limiter)
InvalidOperationException: There was an error reflecting 'data'.
System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, string ns, bool hasWrapperElement, bool rpc,
bool openModel, RecursionLimiter limiter)
有什么问题,如何正确使用?
我也曾尝试将 SOAP 端点添加到 .NET 核心解决方案.. 但它永远不会工作.. 我在某处读到 .NET 核心不支持 WCF 背后的特定想法核心框架 ...
I 've resolved by add an .NET STANDARD external project (as DLL) to my API Project
我引用了它...
[
[
我不知道有没有更好的解决方案..我希望如此..
希望对你有帮助!!!
我有一个(似乎)旧的 ASMX 服务,需要将它用于 .NET Core 2.2。 首先,当我尝试将其添加为 WCF 服务时,我在尝试使用时遇到错误:
InvalidOperationException: The top XML element 'data' from namespace '' references distinct types ServiceReference1.WSIssueNewPayrollCardData and ServiceReference1.WSIssueNewPersonalizedPayrollCardData. Use XML attributes to specify another XML name or namespace for the element or types.
System.Xml.Serialization.XmlReflectionImporter.ReconcileAccessor(Accessor accessor, NameTable accessors)
InvalidOperationException: There was an error reflecting 'data'.
System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, string ns, bool hasWrapperElement, bool rpc, bool openModel, RecursionLimiter limiter)
好的,转到 WSIssueNewPayrollCardData
的定义并为每个 public 属性 添加命名空间,它已经具有相同的名称:
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.0.1")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://com.tch.cards.service/types")]
public partial class WSIssueNewPayrollCardData
{
private string shipToFirstField;
private string shipToLastField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0, Namespace = "http://com.tch.cards.service/types/WSIssueNewPayrollCardData")]
public string shipToFirst
{
get
{
return this.shipToFirstField;
}
set
{
this.shipToFirstField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1, Namespace = "http://com.tch.cards.service/types/WSIssueNewPayrollCardData")]
public string shipToLast
{
get
{
return this.shipToLastField;
}
set
{
this.shipToLastField = value;
}
}
/// <remarks/>
}
那就开始吧。 但是我面对另一个问题:
InvalidOperationException: The Form property may not be 'Unqualified' when an explicit Namespace property is present. System.Xml.Serialization.XmlReflectionImporter.CheckForm(XmlSchemaForm form, bool isQualified)
InvalidOperationException: There was an error reflecting property 'shipToFirst'. System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, bool openModel, string typeName, RecursionLimiter limiter)
InvalidOperationException: There was an error reflecting type 'ServiceReference1.WSIssueNewPayrollCardData'. System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, string ns, ImportContext context, string dataType, XmlAttributes a, bool repeats, bool openModel, RecursionLimiter limiter)
InvalidOperationException: There was an error reflecting 'data'. System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, string ns, bool hasWrapperElement, bool rpc, bool openModel, RecursionLimiter limiter)
有什么问题,如何正确使用?
我也曾尝试将 SOAP 端点添加到 .NET 核心解决方案.. 但它永远不会工作.. 我在某处读到 .NET 核心不支持 WCF 背后的特定想法核心框架 ...
I 've resolved by add an .NET STANDARD external project (as DLL) to my API Project
我引用了它...
[
我不知道有没有更好的解决方案..我希望如此..
希望对你有帮助!!!