[
http://issues.apache.org/jira/browse/AXISCPP-966?page=comments#action_12436902
]
Jean Vincent commented on AXISCPP-966:
--------------------------------------
I have reproduced the issue,with this WSDL extract (complexType MTM generating
MTM.cpp):
<xsd:complexType name="MTM">
<xsd:complexContent>
<xsd:extension xmlns:tp="java:com.hidden"
base="tp:DataElement">
<xsd:sequence>
<xsd:element name="MTM_MTM_DSD"
maxOccurs="1"
type="xsd:int"
minOccurs="1"
nillable="true">
</xsd:element>
<xsd:element name="FAM_ASS_MAC"
maxOccurs="1"
type="xsd:string"
minOccurs="1"
nillable="true">
</xsd:element>
<xsd:element name="MTM_MTM_NAT"
maxOccurs="1"
type="xsd:string"
minOccurs="1"
nillable="true">
</xsd:element>
<xsd:element name="MTM_MTM_DSF"
maxOccurs="1"
type="xsd:int"
minOccurs="1"
nillable="true">
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Generates the code:
int Axis_DeSerialize_MTM(MTM* param, IWrapperSoapDeSerializer* pIWSDZ)
{
xsd__int* p_MTM_MTM_DSD = (pIWSDZ->getElementAsInt("MTM_MTM_DSD",0));
param->MTM_MTM_DSD = *p_MTM_MTM_DSD;
delete p_MTM_MTM_DSD;
xsd__string* p_FAM_ASS_MAC =
(pIWSDZ->getElementAsString("FAM_ASS_MAC",0));
param->FAM_ASS_MAC = *p_FAM_ASS_MAC;
delete p_FAM_ASS_MAC;
xsd__string* p_MTM_MTM_NAT =
(pIWSDZ->getElementAsString("MTM_MTM_NAT",0));
param->MTM_MTM_NAT = *p_MTM_MTM_NAT;
delete p_MTM_MTM_NAT;
xsd__int* p_MTM_MTM_DSF = (pIWSDZ->getElementAsInt("MTM_MTM_DSF",0));
param->MTM_MTM_DSF = *p_MTM_MTM_DSF;
delete p_MTM_MTM_DSF;
return pIWSDZ->getStatus();
}
Should have been (!!! in front of modified lines, 4 lines removed):
int Axis_DeSerialize_MTM(MTM* param, IWrapperSoapDeSerializer* pIWSDZ)
{
xsd__int* p_MTM_MTM_DSD = (pIWSDZ->getElementAsInt("MTM_MTM_DSD",0));
param->MTM_MTM_DSD = *p_MTM_MTM_DSD;
delete p_MTM_MTM_DSD;
!!! param->FAM_ASS_MAC = pIWSDZ->getElementAsString("FAM_ASS_MAC",1);
!!! param->MTM_MTM_NAT = pIWSDZ->getElementAsString("MTM_MTM_NAT",1);
xsd__int* p_MTM_MTM_DSF = (pIWSDZ->getElementAsInt("MTM_MTM_DSF",0));
param->MTM_MTM_DSF = *p_MTM_MTM_DSF;
delete p_MTM_MTM_DSF;
return pIWSDZ->getStatus();
}
The problem comes from the mis-handling of the nillable="true" attribute value
in the WSDL in the code line 661 in writeDeSerializeGlobalMethod at
src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java:
if (attribs[i].isNillable()
|| attribs[i].getTypeName().equals("xsd__anyURI")
|| attribs[i].getTypeName().equals("xsd__QName")
|| attribs[i].getTypeName().equals("xsd__NOTATION"))
{
//TODO handle optional attributes
writer.write("\t"
+ attribs[i].getTypeName()
+ "* p_"
+ attribs[i].getParamNameAsMember()
+ " = (pIWSDZ->"
+ CUtils.getParameterGetValueMethodName(attribs[i]
.getTypeName(), attribs[i].isAttribute())
+ "(\"" + attribs[i].getParamName() + "\",0));\n");
writer.write("\tparam->"
+ attribs[i].getParamNameAsMember() + " = *p_"
+ attribs[i].getParamNameAsMember() + ";\n");
writer.write("\tdelete p_"
+ attribs[i].getParamNameAsMember() + ";\n");
}
else if (attribs[i].getTypeName().equals("xsd__string")
|| isElementNillable(i))
{
writer.write("\tparam->"
+ attribs[i].getParamNameAsMember()
+ " = pIWSDZ->"
+ CUtils.getParameterGetValueMethodName(attribs[i]
.getTypeName(), attribs[i].isAttribute())
+ "(\"" + attribs[i].getParamName() + "\",0);\n");
}
The problem is the that isNillable() test get precedence over
getTypeName().equals("xsd__string") and hence generates the wrong code with the
additional pointer reference and superflous delete.
This code has lots of TODO and probably much more issues, needs serious work
and should be considered alpha code.
> WSDL2WS generate wrong code: redundant value reference * in Wrapper
> -------------------------------------------------------------------
>
> Key: AXISCPP-966
> URL: http://issues.apache.org/jira/browse/AXISCPP-966
> Project: Axis-C++
> Issue Type: Bug
> Components: WSDL processing - RPC
> Affects Versions: 1.6 Beta
> Environment: Platform:
> Linux fedora 3.0
> Axis version:
> Server-side Axis C++ 1.6Beta
> XML Parser Lib:
> xersesc 2.6
> WSDL2ws tool by using axis java 1.3
> Client-side version Axis java 1.3
> Http Server Version:
> Apache 2.0.53
> Tomcat 2.0.58
> Reporter: Michael Xiong
> Priority: Critical
>
> [Error Statement]:
> I have used AxisCPP1.6Beta version to generate SampleTestSoapWrapper.cpp as
> the below:
> Function: int SampleTestSoapWrapper::GetOperation(void* pMsg)
> xsd_string v0 = *(pIWSDZ->getElementAsString("ListType", 0));
> The generated code has bug: xsd_string is already indeed a "char *", so
> should not reference it's content by "*".
> The correct code I expected is:
> xsd_string v0 = pIWSDZ->getElementAsString("ListType", 0);
> [solution]:
> I have investigated the source code of AxisCPP/WSDL2Ws tool, and found that
> if I modify the following code at about line 217~234 in writeMethodInWrapper
> method that belongs to WrapWriter (wsdl2ws/cpp/iteral) class, the above bug
> can be resolved.
> else
> {
>
> writer.write(
> "\t"
> + paraTypeName
> + " v"
> + i
> //<mxiong debug 20060425
> + " = pIWSDZ->"
> // + " = *(pIWSDZ->"
> //>mxiong debug 20060425
> + CUtils.getParameterGetValueMethodName(
> paraTypeName,
> false)
> + "(\""
> + elementName
> // <mxiong debug 20060425
>
> // + "\",0));\n");
> + "\",0);\n");
> // >mxiong debug 20060425
>
> }
> So I think it's a bug.
> [other]
> I will create a patch for you and upload it later.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]