Issue when sending abstract class to .NET webservice with Axis
I am testing some interoperability between a Java Client usint Axis and a .NET ASMX Webservice and am experiencing a problem and was wondering if anyone has an idea of what is going on.
If I have a class that contains a data member that is abstract and try to pass a derived class type into the webservice an XML error is generated. If I receive the same exact structure from the webservice all works as expected.
I have a full .net webservice and java client that will demonstrate the issue if there is an interest.
I am including the soap messages that are received on the service. The class definition follows the SOAP Messages.
Thanks,
Dave
WebbertSolutions[at]hotmail[dot]com
Good Message
- don't send address in
- receive address
==============================
----- SoapRequest at 2/27/2007 2:01:41 PM -----
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<GetAdmin xmlns="urn:emp:service">
<ns1:person xmlns:ns1="urn:emp:data">
<ns1:Name>Hello World</ns1:Name>
<ns1:Age>12</ns1:Age>
</ns1:person>
</GetAdmin>
</soapenv:Body>
</soapenv:Envelope>
----- SoapResponse at 2/27/2007 2:01:41 PM -----
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetAdminResponse xmlns="urn:emp:service">
<GetAdminResult xsi:type="Admin" xmlns="urn:emp:data">
<Name>Hello World</Name>
<Age>12</Age>
<Address xsi:type="HomeAddress">
<HouseNumber>234 State Street</HouseNumber>
</Address>
<HasPassword>true</HasPassword>
</GetAdminResult>
</GetAdminResponse>
</soap:Body>
</soap:Envelope>
Bad Message
- populate HomeAddress
- send HomeAddress in
==============================
----- SoapRequest at 2/27/2007 2:01:13 PM -----
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<GetAdmin xmlns="urn:emp:service">
<ns1:person xmlns:ns1="urn:emp:data">
<ns1:Name>Hello World</ns1:Name>
<ns1:Age>12</ns1:Age>
<ns1:Address />
</ns1:person>
</GetAdmin>
</soapenv:Body>
</soapenv:Envelope>
----- SoapResponse at 2/27/2007 2:01:13 PM -----
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (1, 353). ---> System.InvalidOperationException: The specified type is abstract: name='Address', namespace='urn:emp:data', at <Address xmlns='urn:emp:data'>.
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read5_Address(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read6_Person(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read7_GetAdmin()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
public abstract class PersonBase
{
protected PersonBase() { }
private string _name;
public string Name
{
get { return ( _name ); }
set { _name = value; }
}
}
public class Person : PersonBase
{
private int _age;
private Address _address;
public int Age
{
get { return ( _age ); }
set { _age = value; }
}
public Address Address
{
get { return ( _address ); }
set { _address = value; }
}
}
public abstract class Address
{
protected Address() { }
}
public class HomeAddress : Address
{
public HomeAddress() { }
private string _houseNumber;
public string HouseNumber
{
get { return ( _houseNumber ); }
set { _houseNumber = value; }
}
}