1

In my web service I want to get rid of the generated ArrayOf... definitions in the WSDL which are generated by calling ...service.svc?singleWsdl.

Currently the definiton looks like (and I tried all varieties using XmlArray, etc.):

[DataContract]
public class Incident {...}

[CollectionDataContract(Name = "IncidentList", ItemName = "IncidentItem")]
public class IncidentList : List<Incident>
{
    public IncidentList()
        : base()
    {      }

    public IncidentList(IEnumerable<Incident> list)
        : base(list)
    {        }
}

[MessageContract]
public class IncidentsResponse
{
    [MessageBodyMember]
    public Incident[] Incidents { get; set; }

    [MessageBodyMember]
    public IncidentList IncidentList { get; set; }
}

When I get the WSDL I always receive (more or less - depending on Name attributes, etc.):

<xs:element name="IncidentsResponse"> <xs:complexType><xs:sequence> <xs:element minOccurs="0" maxOccurs="1" name="IncidentList" type="tns:ArrayOfIncident"/><xs:element minOccurs="0" maxOccurs="1" name="Incidents" type="tns:ArrayOfIncident"/> </xs:sequence> </xs:complexType></xs:element>

What I would really like to have is the types listed directly inside the element like

<xs:element name="IncidentsResponse"> <xs:complexType> <Incidents><IncidentItem>...</IncidentItem><IncidentItem>...</IncidentItem> </Incidents> <IncidentList><IncidentItem>...</IncidentItem><IncidentItem>...</IncidentItem></IncidentList> </xs:complexType></xs:element>

So a reference to the actual data as such, not the list type (ArrayOf).

Any way to achieve this? The CollectionDataContract attribute is supposed to do the trick if I get the info right, but somehow it doesn't...

Especially as the consuming client is Java this extra indirection is hurting a bit as it bloats the code

Any ideas welcome :-)

1 Answers1

0

this is intended since wcf can be used across language so it should support common types rather than only supporting .net specific type. still if u want to generate a proxy using svcutil with list then you can create it by using the sample svcutil wsdl /ct:System.Collections.Generic.List`1 or if you are using adding service reference then there is an advanced button , Click that button and select the System.Generic.List as your Collection. This will resolve the problem.. and having the array information will not harm anything so it can be left as it is.

srsyogesh
  • 609
  • 5
  • 17
  • The problem is just that the client is a Java client (thus no svcutil) and it gets the WSDL by calling the service using http://.../service.svc?singleWsdl. Especially this extra class (ArrayOf...) is then generated in Java as well and causing an (unnecessary) indirection. I mean the world doesn't stop turning - it's just ugly and I would love to be able to get rid of it especially as MS mentions that the output behaviour can be adjusted - just the question is how :-) – tipsy-wombat Jun 15 '13 at 07:17
  • Since the client is java it can't understand the List class defined in .Net , that is the reason WSDL generates the type (this is why we have Common language specification so that you can do interoperability) which Java can also understand . If your client is .Net then trying to change the type makes sense still do you want the change the type if so then i dont understand the purpose of doing this and also i dont know what type you will mention to make it interoperable ? or did i understand your question wrong . – srsyogesh Jun 17 '13 at 06:33