You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Nadir Amra <am...@us.ibm.com> on 2006/06/26 05:20:32 UTC
the handling of nested anonymous types
The handling of a nested anonymous type is not performed correctly. For
example, something like:
<element name="getCityInfoStringResponse">
<complexType>
<sequence>
<element name="getCityInfoStringReturn" nillable="true" type="
xsd:string"/>
<element name="MultiCompany">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Companies"
type="xsd:string"/>
<xsd:element name="Warning" type=
"xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</element>
</sequence>
</complexType>
</element>
You will not get MultiCompany class defined and in various parts of the
code you will invalid code generated, such as in prototypes you would get
AXIS_OUT_PARAM >_getCityInfoStringResponse_MultiCompany
In this particular case, I was able to solve the problem by updating the
code in WSDL2Ws.java, method exposeMessagePartsThatAreAnonymousTypes() by
removing the the following check:
&& !(type.getQName().getLocalPart().toString().lastIndexOf(">")>1)
from
if(type.getQName().getLocalPart().toString().startsWith(
">")&& !(type.getQName().getLocalPart().toString().lastIndexOf(">")>1))
And updating the newTypeName from
QName newTypeName = new QName(parameterType.getName().getNamespaceURI(),
parameterType.getName().getLocalPart().substring(1));
to
QName newTypeName = new QName(parameterType.getName().getNamespaceURI(),
parameterType.getName().getLocalPart().substring(1).replaceAll(">",
"_"));
Although this fixed this particular problem, I do not think this is a
complete fix (I added another anonymous type nested within the
MultiCompany called MultiCompany2 and it did not get processed). I have
been studying the code and basically I am wondering why I also should not
remove the check from method exposeNestedTypesThatAreAnonymousTypes:
&& name.lastIndexOf(">")>0
from line 875:
if(name.startsWith(">") && name.lastIndexOf(">")>0)
and similarly, remove the check from method exposeReferenceTypes():
&& referencedType.getQName().getLocalPart().lastIndexOf(">") == 0
from line 1435:
if(referencedType!=null &&
referencedType.getQName().getLocalPart().startsWith(">") &&
referencedType.getQName().getLocalPart().lastIndexOf(">") == 0)
I guess I do not understand why we check if there are no more ">"
characters, since in nested types there might be multiple ">" characters.
In addition, the language specific name in info/Types.java's Type method
has the following code:
if (this.languageSpecificName.charAt(0) == '>')
{
this.languageSpecificName =
">"
+
this.languageSpecificName.substring(1).replaceAll(
">",
"_");
}
Nadir K. Amra
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org
Re: the handling of nested anonymous types
Posted by John Hawkins <HA...@uk.ibm.com>.
I can't remember why I did this but it failed a specific test (probably a
unit test but i can't remember)
Nadir Amra <am...@us.ibm.com>
26/06/2006 04:20
Please respond to
"Apache AXIS C Developers List" <ax...@ws.apache.org>
To
"Apache AXIS C Developers List" <ax...@ws.apache.org>
cc
Subject
the handling of nested anonymous types
The handling of a nested anonymous type is not performed correctly. For
example, something like:
<element name="getCityInfoStringResponse">
<complexType>
<sequence>
<element name="getCityInfoStringReturn" nillable="true" type="
xsd:string"/>
<element name="MultiCompany">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Companies"
type="xsd:string"/>
<xsd:element name="Warning" type=
"xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</element>
</sequence>
</complexType>
</element>
You will not get MultiCompany class defined and in various parts of the
code you will invalid code generated, such as in prototypes you would get
AXIS_OUT_PARAM >_getCityInfoStringResponse_MultiCompany
In this particular case, I was able to solve the problem by updating the
code in WSDL2Ws.java, method exposeMessagePartsThatAreAnonymousTypes() by
removing the the following check:
&& !(type.getQName().getLocalPart().toString().lastIndexOf(">")>1)
from
if(type.getQName().getLocalPart().toString().startsWith(
">")&& !(type.getQName().getLocalPart().toString().lastIndexOf(">")>1))
And updating the newTypeName from
QName newTypeName = new QName(parameterType.getName().getNamespaceURI(),
parameterType.getName().getLocalPart().substring(1));
to
QName newTypeName = new QName(parameterType.getName().getNamespaceURI(),
parameterType.getName().getLocalPart().substring(1).replaceAll(">",
"_"));
Although this fixed this particular problem, I do not think this is a
complete fix (I added another anonymous type nested within the
MultiCompany called MultiCompany2 and it did not get processed). I have
been studying the code and basically I am wondering why I also should not
remove the check from method exposeNestedTypesThatAreAnonymousTypes:
&& name.lastIndexOf(">")>0
from line 875:
if(name.startsWith(">") && name.lastIndexOf(">")>0)
and similarly, remove the check from method exposeReferenceTypes():
&& referencedType.getQName().getLocalPart().lastIndexOf(">") == 0
from line 1435:
if(referencedType!=null &&
referencedType.getQName().getLocalPart().startsWith(">") &&
referencedType.getQName().getLocalPart().lastIndexOf(">") == 0)
I guess I do not understand why we check if there are no more ">"
characters, since in nested types there might be multiple ">" characters.
In addition, the language specific name in info/Types.java's Type method
has the following code:
if (this.languageSpecificName.charAt(0) == '>')
{
this.languageSpecificName =
">"
+
this.languageSpecificName.substring(1).replaceAll(
">",
"_");
}
Nadir K. Amra
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org