3

I'm using a standard wsdl (located here) to communicate with a service (OpenXDS). I created a service reference from it, which generated a very large Reference.cs file. There is a type hierarchy in the file like 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 three types have the same XmlType:

[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0")]

There is a collection in the 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 the service actually responds, it gives a 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 the trace log and I can get the same answer in SoapUI. But when I get the deserialized response back from the client proxy, the RegistryObjectList is empty. It completely ignores the ExtrinsicObject elements.

I can't change the server, and the client is generated by VS2012. It seems like this should just work and I'm missing some setting or something.

Here's the theories I have so far:

  • There's some setting on the service reference, and if I checked it and updated the code everything would just work.
  • The wsdl I'm using is different than the wsdl they have agreed to.
  • I'm going to have to figure out how to manually deserialize the responses.

Any help is appreciated. I've tried to include what I thought was pertinent, but there was a lot of editing since the wsdl, xsd's, and Reference.cs are all fairly large.

qanwi1970
  • 103
  • 7
  • What I try in such cases is build a stub C# server yourself from the WSDL and see how the response it sends differs from the one the real server sends. – Yaron Naveh Sep 04 '13 at 16:29
  • The link to the wsdl doesn't work.... – tom redfern Sep 05 '13 at 07:49
  • It seems like it cut off the end. Use https://code.google.com/p/epsos-common-components/source/browse/ihe-profiles/src/wsdl/XCARespondingGatewayQuery.wsdl?r=e6bea12e067eb13d9276b8da7c9667a45ec5685f – qanwi1970 Sep 05 '13 at 23:16

1 Answers1

0

I just got this working by passing the following XmlAttributeOverrides to the 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 what I understand, Reference.cs, as you 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 the XML, the RegistryObjectList element does not have Identifiable child nodes, but rather ExtrinsicObject and RegistryPackage children, what I really want is for it to look like 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 the overrides gets the serializer to ignore the original attributes and treat RegistryObjectList as if had been decorated with the latter.

Rich Bennema
  • 10,295
  • 4
  • 37
  • 58