c# - wcf client ignores derived types during deserialization -


i'm using standard wsdl (located here) communicate service (openxds). created service reference it, generated large reference.cs file. there type hierarchy in file this:

public partial class extrinsicobjecttype : registryobjecttype 

. . .

[system.xml.serialization.xmlincludeattribute(typeof(extrinsicobjecttype))] public partial class registryobjecttype : identifiabletype 

. . .

[system.xml.serialization.xmlincludeattribute(typeof(registryobjecttype))] [system.xml.serialization.xmlincludeattribute(typeof(extrinsicobjecttype))] public partial class identifiabletype : object 

all 3 types have same xmltype:

[system.xml.serialization.xmltypeattribute(namespace="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0")] 

there collection in response type of identifiabletype objects:

[system.xml.serialization.xmlarrayattribute(namespace="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", order=0)] [system.xml.serialization.xmlarrayitemattribute("identifiable", isnullable=false)] public identifiabletype[] registryobjectlist {  

when service responds, gives collection of extrinsicobject elements:

<rim:registryobjectlist xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0">   <ns1:extrinsicobject xmlns:ns1="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" ...   <ns1:extrinsicobject xmlns:ns1="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" ...   <ns1:extrinsicobject xmlns:ns1="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" ...   <ns1:extrinsicobject xmlns:ns1="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" ...   <ns1:extrinsicobject xmlns:ns1="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" ... </rim:registryobjectlist> 

i see these elements in trace log , can same answer in soapui. when deserialized response client proxy, registryobjectlist empty. ignores extrinsicobject elements.

i can't change server, , client generated vs2012. seems should work , i'm missing setting or something.

here's theories have far:

  • there's setting on service reference, , if checked , updated code work.
  • the wsdl i'm using different wsdl have agreed to.
  • i'm going have figure out how manually deserialize responses.

any appreciated. i've tried include thought pertinent, there lot of editing since wsdl, xsd's, , reference.cs large.

i got working passing following xmlattributeoverrides serializer:

var overrides = new xmlattributeoverrides(); overrides.add(typeof(submitobjectsrequest), "registryobjectlist", new xmlattributes {     xmlarray = new xmlarrayattribute()     {         namespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0",         order = 0     },     xmlarrayitems =     {         new xmlarrayitemattribute("extrinsicobject", typeof(extrinsicobjecttype)) { isnullable = false },         new xmlarrayitemattribute("registrypackage", typeof(registrypackagetype)) { isnullable = false }     } }); 

from understand, reference.cs, said, gives this:

[system.xml.serialization.xmlarrayattribute(namespace="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", order=0)] [system.xml.serialization.xmlarrayitemattribute("identifiable", isnullable=false)] public identifiabletype[] registryobjectlist { 

but since, in xml, registryobjectlist element not have identifiable child nodes, rather extrinsicobject , registrypackage children, want this:

[system.xml.serialization.xmlarrayattribute(namespace="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", order=0)] [system.xml.serialization.xmlarrayitemattribute("extrinsicobject", typeof(extrinsicobjecttype), isnullable=false)] [system.xml.serialization.xmlarrayitemattribute("registrypackage", typeof(registrypackagetype), isnullable=false)] public identifiabletype[] registryobjectlist { 

and including overrides gets serializer ignore original attributes , treat registryobjectlist if had been decorated latter.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -