Creating contracts for XmlSerializer

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

When working with XmlSerializer you might notice that you generated contract contains double definitions for some or all types.
This is shown at two following pictures. As you can see at marked places it is obvious that double definition comes form DataContract serializer, although you just want to use XmlSerializer.

 

image

 

 

image

Next picture shows what causes this behavior.

image

XmlSerializerFormatAttribute enforces Metadata Exporter to create DataContract version of types. To workaround this remove this attribute from all operations:

 

 

 

[System.ServiceModel.OperationContractAttribute(Action = "urn:epcglobal:epcis:wsdl:1:EPCISServicePortType:captureRequest", ReplyAction = "urn:epcglobal:epcis:wsdl:1:EPCISServicePortType:captureResponse")]

//[System.ServiceModel.ServiceKnownTypeAttribute(typeof(EPCISException))]

[System.ServiceModel.FaultContractAttribute(typeof(EPCISException), Action = "http://www.w3.org/2005/08/addressing/soap/fault", Name = "EPCISException", Namespace = "urn:epcglobal:epcis-query:xsd:1")]

[System.ServiceModel.FaultContractAttribute(typeof(ValidationException), Action = "http://www.w3.org/2005/08/addressing/soap/fault", Name = "ValidationException", Namespace = "urn:epcglobal:epcis-query:xsd:1")]

[System.ServiceModel.XmlSerializerFormatAttribute()]

captureResponse capture(captureRequest req);

[System.ServiceModel.OperationContractAttribute(Action = "urn:epcglobal:epcis:wsdl:1:EPCISServicePortType:getQueryNamesRequest", ReplyAction = "urn:epcglobal:epcis:wsdl:1:EPCISServicePortType:getQueryNamesResponse")]

[System.ServiceModel.FaultContractAttribute(typeof(SecurityException), Action = "http://www.w3.org/2005/08/addressing/soap/fault", Name = "SecurityException", Namespace = "urn:epcglobal:epcis-query:xsd:1")]

[System.ServiceModel.FaultContractAttribute(typeof(ValidationException), Action = "http://www.w3.org/2005/08/addressing/soap/fault", Name = "ValidationException", Namespace = "urn:epcglobal:epcis-query:xsd:1")]

[System.ServiceModel.FaultContractAttribute(typeof(ImplementationException), Action = "http://www.w3.org/2005/08/addressing/soap/fault", Name = "ImplementationException", Namespace = "urn:epcglobal:epcis-query:xsd:1")]

[System.ServiceModel.XmlSerializerFormatAttribute()]

getQueryNamesResponse getQueryNames(getQueryNamesRequest request);

/// <remarks/>
   [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
   [System.SerializableAttribute()]
   [System.Diagnostics.DebuggerStepThroughAttribute()]
   [System.ComponentModel.DesignerCategoryAttribute("code")]
   [System.Xml.Serialization.XmlTypeAttribute(TypeName="ValidationException", Namespace="
http://schemas.datacontract.org/2004/07/Daenet.Tracking.Epcis")]
   public partial class ValidationException1 : EPCISException1 {
      
       private PropertyResult1[] propertyResultListField;
      
       /// <remarks/>
       [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=0)]
       [System.Xml.Serialization.XmlArrayItemAttribute(Namespace="
http://schemas.datacontract.org/2004/07/Daenet.Tracking")]
       public PropertyResult1[] PropertyResultList {
           get {
               return this.propertyResultListField;
           }
           set {
               this.propertyResultListField = value;
               this.RaisePropertyChanged("PropertyResultList");
           }
       }
   }

 


Posted Jan 06 2011, 11:18 AM by Damir Dobric
Filed under:

Comments

Priest wrote re: Creating contracts for XmlSerializer
on 10-03-2011 16:59

Holy szhinit, this is so cool thank you.

developers.de is a .Net Community Blog powered by daenet GmbH.