Forum Discussion

Tom_Gibbons's avatar
Tom_Gibbons
New Contributor
16 years ago

Use Of XmlInclude

The web method I am testing is written in C#.Net.  The web interface is defined as using a list of a baseclasses, call it Txn, as input.  Within the code, there are two subclasses that inherit this baseclass, call them Txn1 and Txn2.  The web method is decorated with two XmlIncludes, e.g. [XmlInclude(typeof(Txn1))] and [XmlInclude(typeof(Txn2))].

This is a closed system.  The clients of the web method only ever send lists of Txn1 and Txn2 records.  By the way, the data stream is compressed using GZip, not an issue per se but inhibits the use of a sniffer.  Within the C# code, we loop through each of the incoming Txn records, check the type, e.g. is it of type Txn1 or Txn2, then perform appropriate processing.

When opening a SoapUI project, I point to the web services WSDL via a URL.  The request interface is created but reflects only the base class, Txn.  I created a dummy web service using a web method that simply accepts one of the subclasses, Txn1, then created a new SoapUI project pointing the URL to this new dummy web service and received a request that reflects the Txn1 fields.  I modified my original request, the XML of which reflects the composition of the baseclass, Txn, to include the extended fields of Txn1.  My intention is to have this request appear to the web method as a Txn1 record.

After monkeying around a while, I am able to get the service to receive and begin processing the request, but once we get to the conditional, described above, that inspects the Txn type, I have an issue.  I cannot figure out how to pass in a Txn of type Txn1.  I have read a few articles, such as http://www.pluralsight.com/community/bl ... /1580.aspx and have monkeyed around a bit but with no success.

I believe the real issue is, how do I structure the XML within the SoapUI Request to deal with an interface that uses XmlIncludes.

Any thoughts...

2 Replies

  • Well,  I ended up modifying the server-side soapextension to output the incoming XML representation of the service request to an event log.  I then called the service once for each of the extended types.  I then copied the XML from those log messages and pasted them into the test request.  That worked perfectly.