"Refresh Service Link" Changes the definition of some types of proxies

I just made the link "Update Service" to make one change. One operation was added to the service, and we wanted to use it.

Unfortunately, in different XML namespaces, there were two proxy classes with the same name. The service link generated them as "Entity" and "Entity1" in the service link namespace.

The launch of the Update Helpdesk changed the order of these classes, so now there was "Entity" - "Entity1" and vice versa!

Is there any way to make these generated class names stable? Something that would allow me to say: "for complexType A in the namespace y, make this Entity, and for complexType A in the namespace z make this Entity1." Thus, the order cannot change.

PS The truly unfortunate thing is that about an hour is left on this contract - literally not tomorrow!

+3
source share
2 answers

To override the default naming behavior and resolve conflicts yourself, set the Name DataContractAttributealternate name for the property explicitly:

[DataContract(Name="Entity1")]
public class Entity
{ ... }
+2
source

/ VS Add/Update .svcmap(, ). . , , . NamespaceMappings, WSDL XML shema CLR.

, :

namespace EntitiesServiceLibEntity1
{
    [DataContract]
    public class Entity
    {
        [DataMember]
        public string StringValue
        {
            get { return m_stringValue; }
            set { m_stringValue = value; }
        }

        private string m_stringValue;
    }
}

:

namespace EntitiesServiceLibEntity2
{
    [DataContract]
    public class Entity
    {
        [DataMember]
        public int IntValue
        {
            get { return m_intValue; }
            set { m_intValue = value; }
        }

        private int m_intValue;
    }
}

" " . Reference.svcmap, NamespaceMappings:

<NamespaceMappings>
  <NamespaceMapping TargetNamespace="http://schemas.datacontract.org/2004/07/EntitiesServiceLibEntity1" ClrNamespace="EntitiesServiceLibEntity1" />
  <NamespaceMapping TargetNamespace="http://schemas.datacontract.org/2004/07/EntitiesServiceLibEntity2" ClrNamespace="EntitiesServiceLibEntity2" />
</NamespaceMappings>

() :

EntitiesServiceLibEntity1.Entity entity1 = client.GetEntity1();
EntitiesServiceLibEntity2.Entity entity2 = client.GetEntity2();

( , ), DataContract.Name , @Patrice Gahide.

+2

All Articles