C# .NETCore2.2:如何使用WSDL进行WCF引用

C# .NETCore2.2:如何使用WSDL进行WCF引用,c#,web-services,wcf,.net-core,wsdl,C#,Web Services,Wcf,.net Core,Wsdl,我有一个旧的(似乎)ASMX服务,需要将其用于.NETCore2.2。 首先,当我尝试将其添加为WCF服务时,我在尝试使用时遇到了一个错误: InvalidOperationException: The top XML element 'data' from namespace '' references distinct types ServiceReference1.WSIssueNewPayrollCardData and ServiceReference1.WSIssueNewPerso

我有一个旧的(似乎)ASMX服务,需要将其用于.NETCore2.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的定义,为每个已具有相同名称的公共属性添加名称空间:

[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/>

}
[System.CodeDom.Compiler.GeneratedCodeAttribute(“dotnet svcuti”,“1.0.0.1”)]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(命名空间=”http://com.tch.cards.service/types")]
公共部分类WSIssueNewPayrollCardData
{
私有字符串shipToFirstField;
私有字符串shipToLastField;
/// 
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified,Order=0,Namespace=”http://com.tch.cards.service/types/WSIssueNewPayrollCardData")]
公共字符串shipToFirst
{
得到
{
返回此.shipToFirstField;
}
设置
{
this.shipToFirstField=值;
}
}
/// 
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified,Order=1,Namespace=”http://com.tch.cards.service/types/WSIssueNewPayrollCardData")]
公共字符串shipToLast
{
得到
{
返回此.shipToLastField;
}
设置
{
this.shipToLastField=值;
}
}
/// 
}
那就开始吧。 但我面对另一个问题:

InvalidOperationException:表单属性不能为“不合格” 当显式命名空间属性存在时。 System.Xml.Serialization.XmlReflectionImporter.CheckForm(XmlSchemaForm 表格,bool(合格)

InvalidOperationException:反映属性时出错 “shipToFirst”。 System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping 映射,StructModel模型,bool openModel,字符串类型名, 递归限制器(限制器)

InvalidOperationException:存在反映类型的错误 “ServiceReference1.WSIssueNewPayrollCardData”。 System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(类型模型 模型、字符串ns、ImportContext上下文、字符串数据类型、, XMLA属性,布尔重复,布尔openModel,递归限制器 限制器)

InvalidOperationException:反映“数据”的错误。 System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers、字符串ns、bool hasWrapperElement、bool rpc、, bool openModel,递归限制器(限制器)


出了什么问题,如何正确使用它?

I'va还尝试将SOAP端点添加到.NET核心解决方案中。。而且它从来都不起作用。。我在某个地方读到,.NETCore不支持WCF,因为.NETCore框架背后有一个特定的想法

我已通过将.NET标准外部项目(作为DLL)添加到我的API项目中来解决此问题
,并在其中引用了它

[ [

我不知道有没有更好的解决办法我希望如此


希望对您有所帮助!!!

从描述来看,客户端和服务器之间的序列化和反序列化可能存在一些问题,这是由类的名称空间引起的。我认为我们应该在服务器端手动将xml名称空间属性添加到这些类中。