You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Anne Thomas Manes <at...@gmail.com> on 2007/03/02 15:11:03 UTC
Re: Issue with Axis when sending abstract class to .NET webservice
David,
You cannot send an element of an abstract type. Your choices:
- don't send the <Address/> element (requires minOccurs="0")
- define it as a concrete type
Anne
On 3/1/07, David Elliott <we...@hotmail.com> wrote:
>
> I am testing some interoperability between a Java Client using 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
> anyone wants the code.
>
> 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; }
> }
> }
>
>
> ________________________________
> Explore the seven wonders of the world Learn more!
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
Re: Issue with Axis when sending abstract class to .NET webservice
Posted by vladicaognjanovic <vl...@gmail.com>.
Can some please help, I have a same problem but once again:
server side (web service in c#):
public abstract class CatalogValue
{
public int id;
public CatalogValue next;
public CatalogValue()
{
}
}
public class CatalogValueImpl : CatalogValue //Linked list
{
public string name;
public CatalogValueImpl()
{
this.next = null;
}
}
public class DataSource
{
public CatalogValue value;
public DataSource() { }
}
Now the main mistery: this two calls work fine
[WebMethod]
public CatalogValue getCat()
{
CatalogValueImpl i = new CatalogValueImpl();
i.name = "jhjhfdajd";
return i;
}
[WebMethod]
public CatalogValue updateCat(CatalogValue c)
{
c.id = -1;
return c;
}
BUT why this two call dont work:
[XmlInclude(typeof(CatalogValueImpl))]
[WebMethod]
public DataSource get()
{
DataSource ds = new DataSource();
ds.init();
return ds;
}
[XmlInclude(typeof(CatalogValue))]
[XmlInclude(typeof(CatalogValueImpl))]
[WebMethod]
public DataSource update(DataSource value)
{
value = new DataSource();
value.init();
return value;
}
Just to say that on client side (client is in java, and I'm using axis 1.3)
data that I getting from the server is correct, but when I try to call
"update(DataSource value)" I get following error:
xisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
faultSubcode:
faultString: System.Web.Services.Protocols.SoapException: Server was unable
to read request. ---> System.InvalidOperationException: There is an error
in XML document (1, 272). ---> System.InvalidOperationException: The
specified type is abstract: name='CatalogValue',
namespace='http://tempuri.org/', at <value
xmlns='http://tempuri.org/'>.
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read2_CatalogValue(Boolean
isNullable, Boolean checkType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read4_DataSource(Boolean
isNullable, Boolean checkType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read9_update()
at
Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer8.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()
Sorry for any typing mistake, one my arm is broken.
Please Help I need solution for this.
--
View this message in context: http://www.nabble.com/Issue-with-Axis-when-sending-abstract-class-to-.NET-webservice-tf3326681.html#a12449320
Sent from the Axis - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org