users@jax-rpc.java.net

Re: please help - jaxrpc in jwsdp1.2 fails deserializing base/super class

From: Doug Kohlert <Doug.Kohlert_at_Sun.COM>
Date: Fri, 17 Oct 2003 15:30:16 -0700

Nan,
This indeed is a bug. We will fix it for as soon as possible.

Thank you for bringing it to our attention.



Nan Xiong wrote:
> Doug,
> Sorry for the delay. I made a very simple .NET service to reproduce the same problem. Attached in the email is the wsdl file - service1.wsdl.
>
> The .NET service code is very simple in C# as shown below. The problem is demonstrated in sayHello operation, which returns a Hello type, whose Base type is HelloBase, having 2 [XmlAttribute] annotated properties. >From jwsdp jaxrpc client, getMessage() returns proper value, but getName() and getDescription() always returns null.
>
> Let me know if you need more info...
> Thanks again
> Nan
>
> ++++++++++ CUT HERE ++++++++++++
>
> using System;
> using System.Collections;
> using System.ComponentModel;
> using System.Data;
> using System.Diagnostics;
> using System.Web;
> using System.Web.Services;
> using System.Xml.Serialization;
>
> namespace WebService1
> {
> /// <summary>
> /// Summary description for Service1.
> /// </summary>
> [WebService(
> Namespace="http://viewstart.com",
> Name="Hello Web Service",
> Description="My Hello Web Service")]
> public class Service1 : System.Web.Services.WebService
> {
> public Service1()
> {
> //CODEGEN: This call is required by the ASP.NET Web Services Designer
> InitializeComponent();
> }
>
> #region Component Designer generated code
>
> //Required by the Web Services Designer
> private IContainer components = null;
>
> /// <summary>
> /// Required method for Designer support - do not modify
> /// the contents of this method with the code editor.
> /// </summary>
> private void InitializeComponent()
> {
> }
>
> /// <summary>
> /// Clean up any resources being used.
> /// </summary>
> protected override void Dispose( bool disposing )
> {
> if(disposing && components != null)
> {
> components.Dispose();
> }
> base.Dispose(disposing);
> }
>
> #endregion
>
> // WEB SERVICE EXAMPLE
> // The HelloWorld() example service returns the string Hello World
> // To build, uncomment the following lines then save and build the project
> // To test this web service, press F5
>
> [WebMethod]
> public string HelloWorld()
> {
> return "hello world!";
> }
>
> [WebMethod]
> public Hello SayHello()
> {
> Hello hello = new Hello();
> return hello;
> }
> }
>
>
> public abstract class HelloBase
> {
> private string name = "TestName";
> private string description = "TestDesc";
>
> public HelloBase()
> {
> }
>
> [XmlAttribute]
> public virtual string Name
> {
> get
> {
> return name;
> }
> set
> {
> name = value;
> }
> }
>
> [XmlAttribute]
> public virtual string Description
> {
> get
> {
> return description;
> }
> set
> {
> description = value;
> }
> }
>
> }
>
> public class Hello : HelloBase
> {
> private string message="HELLO!";
>
> public Hello()
> {
> }
>
> public virtual string Message
> {
> get
> {
> return message;
> }
> set
> {
> message = value;
> }
> }
> }
>
> }
>
>
>>-----Original Message-----
>>From: Doug Kohlert [mailto:Doug.Kohlert_at_Sun.COM]
>>Sent: Thursday, October 16, 2003 5:59 PM
>>To: users_at_jax-rpc.dev.java.net
>>Subject: Re: please help - jaxrpc in jwsdp1.2 fails deserializing
>>base/super class
>>
>>
>>Nan,
>>You may have discovered a bug. Would it be possible for you to
>>post the entire WSDL you are using?
>>
>>Thanks
>>
>>Nan Xiong wrote:
>>
>>>Hello,
>>>I have a .NET service that uses an abstract base class,
>>
>>where it properties are [XmlAttribute] annotated, meaning
>>that the properties exposed in this abstract base class are
>>serialized into xml attributes
>>
>>>instead of xml elements in the soap message by .NET.
>>>
>>>I created client files using jwsdp1.2 wscompile with
>>
>>-f:searchschema on, the base class's serializer
>>
>>>seems understand those are xml attributes (see pasted
>>
>>generated code), but it appears the doDeserialize()
>>
>>>in the base class never get called at the runtime, the
>>
>>result is that those properties are not get set/deserialized
>>at all on the client side - they are always null.
>>
>>>Same .NET services works properly with a Axis1.1 client.
>>>
>>>I pasted some relevant lines from wsdl and wscompile
>>
>>generated files in this email, please let me know
>>
>>>whether this is a bug in jwsdp, or i some other flags i
>>
>>should used in wscompile? Any workaround for now?
>>
>>>Changing those properties to not [XmlAttribute] annotated,
>>
>>works in jwsdp, but we need this for backward compatibility.
>>If [XmlAttribute] is used in a non base class, it also works on jwsdp.
>>
>>>l can provide more detailed info if needed to.
>>>
>>>Thanks in advance!
>>>Nan
>>>
>>>++++++++++ part of WSDL +++++++++++++++
>>><s:complexType name="ProcessElement" abstract="true">
>>> <s:attribute name="Name" type="s:string" />
>>> <s:attribute name="Description" type="s:string" />
>>> </s:complexType>
>>>
>>><s:complexType name="Worklist">
>>> <s:complexContent mixed="false">
>>> <s:extension base="s0:ProcessElement">
>>> <s:sequence>
>>> <s:element minOccurs="0" maxOccurs="1"
>>
>>name="Template" type="s0:Template" />
>>
>>> </s:sequence>
>>> </s:extension>
>>> </s:complexContent>
>>> </s:complexType>
>>>
>>>++++++++ part of SOAP response from .NET ++++++++++++
>>><Worklist Name="WFSERVE" Description="Default Process
>>
>>Agent"><Template Name="WFTASK"
>>Description="WFTASK"><Fields><Field Name="STATUS"
>>Description="Status"><Displayed>false</Displayed><Type>Short</
>>Type><Label>Status</Label><ColumnLabel>Status</ColumnLabel><Wi
>>dth>0</Width><ColumnWidth>4</ColumnWidth></Field><Field
>>Name=":REQID" Description="Request
>>ID"><Displayed>true</Displayed><Type>Integer</Type><Label>Requ
>>est ID</Label><ColumnLabel>Request
>>ID</ColumnLabel><Width>0</Width><ColumnWidth>11</ColumnWidth><
>>/Field><Field Name=":TSKTYPE" Description="Task
>>Type"><Displayed>true</Displayed><Type>String</Type><Label>Tas
>>k Type</Label><ColumnLabel>Task
>>Type</ColumnLabel><Width>10</Width><ColumnWidth>10</ColumnWidt
>>h></Field><Field Name=":TSKNAME" Description="Task
>>Name"><Displayed>true</Displayed><Type>String</Type><Label>Tas
>>k Name</Label><ColumnLabel>Task
>>Name</ColumnLabel><Width>10</Width><ColumnWidth>11</ColumnWidt
>>h></Field><Field Name=":PRIORITY" Description="Priority"><Displayed
>>
>>>true</Displayed><Type>Integer</Type><Label>Priority</Label><C
>>
>>olumnLabel>Priority</ColumnLabel><Width>0</Width><ColumnWidth>
>>8</ColumnWidth></Field><Field Name=":ASYNC"
>>Description="Async"><Displayed>true</Displayed><Type>String</T
>>ype><Label>Async</Label><ColumnLabel>Async</ColumnLabel><Width
>>
>>>1</Width><ColumnWidth>5</ColumnWidth></Field><Field
>>
>>Name="RECID" Description="Record
>>ID"><Displayed>false</Displayed><Type>Integer</Type><Label>Rec
>>ord ID</Label><ColumnLabel>Record
>>ID</ColumnLabel><Width>0</Width><ColumnWidth>0</ColumnWidth></
>>Field><Field Name="QUEID" Description="Queue
>>ID"><Displayed>false</Displayed><Type>Integer</Type><Label>Que
>>ue ID</Label><ColumnLabel>Queue
>>ID</ColumnLabel><Width>0</Width><ColumnWidth>0</ColumnWidth></
>>Field><Field Name="CPFILE"
>>Description="Filename"><Displayed>false</Displayed><Type>AllCa
>>p</Type><Label>Filename</Label><ColumnLabel>Filename</ColumnLa
>>bel><Width>80</Width><ColumnWidth>0</ColumnWidth></Field></Fie
>>lds></Template></Worklist>
>>
>>>+++++++++ doDeserialize() in the subclass
>>
>>WorkList_LiteralSerializer ++++++++
>>
>>> public Object doDeserialize(XMLReader reader,
>>> SOAPDeserializationContext context) throws Exception {
>>> com.viewstar.webservices.Worklist instance = new
>>
>>com.viewstar.webservices.Worklist();
>>
>>> Object member=null;
>>> QName elementName;
>>> List values;
>>> Object value;
>>>
>>> reader.nextElementContent();
>>> elementName = reader.getName();
>>> if (reader.getState() == XMLReader.START) {
>>> if (elementName.equals(ns1_Template_QNAME)) {
>>> member =
>>
>>ns1_myTemplate_LiteralSerializer.deserialize(ns1_Template_QNAM
>>E, reader, context);
>>
>>> if (member == null) {
>>> throw new
>>
>>DeserializationException("literal.unexpectedNull");
>>
>>> }
>>>
>>
>>instance.setTemplate((com.viewstar.webservices.Template)member);
>>
>>> reader.nextElementContent();
>>> }
>>> }
>>>
>>> XMLReaderUtil.verifyReaderState(reader, XMLReader.END);
>>> return (Object)instance;
>>> }
>>>
>>>++++++++ doDeserialize() in the base class
>>
>>ProcessElement_LiteralSerializer +++++++++
>>
>>> public Object doDeserialize(XMLReader reader,
>>> SOAPDeserializationContext context) throws Exception {
>>> com.viewstar.webservices.ProcessElement instance =
>>
>>new com.viewstar.webservices.ProcessElement();
>>
>>> Object member=null;
>>> QName elementName;
>>> List values;
>>> Object value;
>>>
>>> Attributes attributes = reader.getAttributes();
>>> String attribute = null;
>>> attribute = attributes.getValue(ns3_Name_QNAME);
>>> if (attribute != null) {
>>> member =
>>
>>XSDStringEncoder.getInstance().stringToObject(attribute, reader);
>>
>>> instance.setName((java.lang.String)member);
>>> }
>>> attribute = attributes.getValue(ns3_Description_QNAME);
>>> if (attribute != null) {
>>> member =
>>
>>XSDStringEncoder.getInstance().stringToObject(attribute, reader);
>>
>>> instance.setDescription((java.lang.String)member);
>>> }
>>>
>>> reader.nextElementContent();
>>> XMLReaderUtil.verifyReaderState(reader, XMLReader.END);
>>> return (Object)instance;
>>> }
>>>
>>>
>>
>>---------------------------------------------------------------------
>>
>>>To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
>>>For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
>>>
>>>
>>
>>
>>--
>>Doug Kohlert
>>Java Software Division
>>Sun Microsystems, Inc.
>>phone: 503 345-9806
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
>>For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
>>
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
> For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net


-- 
Doug Kohlert
Java Software Division
Sun Microsystems, Inc.
phone: 503 345-9806
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net