0
votes

I have an old (seems) ASMX service and need to use it for .NET Core 2.2. First at all, when I try to add it as WCF service I got an error when I try to use:

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)

ok, go to definition of WSIssueNewPayrollCardData and add namespace for every public property, which already has the same name:

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

}

then start it. But I face to face with another problem:

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)

what is wrong, how to use it correctly?

1
From the description, there may be some problems with serialization and deserialization between the client and the server, which caused by the namespace of the class. I think we should add the xml namespace property to these class on server side manually.Abraham Qian

1 Answers

1
votes

I'va also tried to add a SOAP Endpoint to a .NET CORE SOLUTION .. and it never work .. I've read somewhere that .NET CORE DOESN't SUPPORT WCF by a specific idea behind .NET CORE FRAMEWORK ...

I 've resolved by add an .NET STANDARD external project (as DLL) to my API Project and in that I' ve reference it ...

[1] [2]

I don't know id there are better solution .. i hope so ..

Hope it helps you!!!