[ 
https://issues.apache.org/jira/browse/AXIS2C-551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12482647
 ] 

Milinda Lakmal Pathirage commented on AXIS2C-551:
-------------------------------------------------

Bug fixed in latest Axis2 svn trunk.

> WSDL2C: generated code does not handle optional elements
> --------------------------------------------------------
>
>                 Key: AXIS2C-551
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-551
>             Project: Axis2-C
>          Issue Type: Bug
>          Components: code generation
>    Affects Versions: Current (Nightly)
>         Environment: Windows XP
>            Reporter: Dave Meier
>
> With an optional element specified in the WSDL, the generated code returns an 
> error if the element is not provided.  In the following WSDL I have an 
> optional element called "name".
> ----------
> WSDL:
> ----------
> <?xml version="1.0" encoding="UTF-8"?>
> <definitions name="test"
>  targetNamespace="http://localhost:80/gsoap/test.wsdl";
>  xmlns:tns="http://localhost:80/gsoap/test.wsdl";
>  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
>  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>  xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#";
>  
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
>  xmlns:ds="http://www.w3.org/2000/09/xmldsig#";
>  
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
>  xmlns:tt="urn:test"
>  xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/";
>  xmlns:MIME="http://schemas.xmlsoap.org/wsdl/mime/";
>  xmlns:DIME="http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/";
>  xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/";
>  xmlns="http://schemas.xmlsoap.org/wsdl/";>
> <types>
>  <schema targetNamespace="urn:test"
>   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
>   xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>   xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>   xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#";
>   
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
>   xmlns:ds="http://www.w3.org/2000/09/xmldsig#";
>   
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
>   xmlns:tt="urn:test"
>   xmlns="http://www.w3.org/2001/XMLSchema";
>   elementFormDefault="qualified"
>   attributeFormDefault="qualified">
>   <import namespace="http://www.w3.org/2001/10/xml-exc-c14n#"/>
>   <import 
> namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"/>
>   <import namespace="http://www.w3.org/2000/09/xmldsig#"/>
>   <import 
> namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
>   <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
>   <simpleType name="Attachment-Access-Type">
>    <restriction base="xsd:string">
>     <enumeration value="ATTACHACCESS-DEFAULT"/>
>     <enumeration value="ATTACHACCESS-RESTRICTED"/>
>     <enumeration value="ATTACHACCESS-UNRESTRICTED"/>
>    </restriction>
>   </simpleType>
>   <!-- operation request element -->
>   <element name="SetAccess">
>    <complexType>
>     <sequence>
>      <element name="name" type="xsd:string" minOccurs="0" maxOccurs="1" 
> nillable="true"/>
>      <element name="activeInactive" type="xsd:boolean" minOccurs="1" 
> maxOccurs="1"/>
>     </sequence>
>    </complexType>
>   </element>
>   <!-- operation response element -->
>   <element name="SetAccessResponse">
>    <complexType>
>     <sequence>
>     </sequence>
>    </complexType>
>   </element>
>  </schema>
> </types>
> <message name="SetAccess">
>  <part name="parameters" element="tt:SetAccess"/>
> </message>
> <message name="SetAccessResponse">
>  <part name="parameters" element="tt:SetAccessResponse"/>
> </message>
> <portType name="testPortType">
>  <operation name="SetAccess">
>   <documentation>SetAccess</documentation>
>   <input message="tns:SetAccess"/>
>   <output message="tns:SetAccessResponse"/>
>  </operation>
> </portType>
> <binding name="test" type="tns:testPortType">
>  <SOAP:binding style="document" 
> transport="http://schemas.xmlsoap.org/soap/http"/>
>  <operation name="SetAccess">
>   <SOAP:operation soapAction=""/>
>   <input>
>      <SOAP:body parts="parameters" use="literal"/>
>   </input>
>   <output>
>      <SOAP:body parts="parameters" use="literal"/>
>   </output>
>  </operation>
> </binding>
> <service name="test">
>  <documentation>gSOAP 2.7.6e generated service definition</documentation>
>  <port name="test" binding="tns:test">
>   <SOAP:address location="http://localhost:80/gsoap/gsoap_ssl.dll?test"/>
>  </port>
> </service>
> </definitions>
> ------------------------
> Generated Code:
> ------------------------
> current_element = AXIOM_NODE_GET_DATA_ELEMENT( current_node, env);
> text_value = AXIOM_ELEMENT_GET_TEXT(current_element, env, current_node );
> if ( NULL == text_value )
> {
>   status = AXIS2_FAILURE;
> }
> else
> {
>   status = AXIS2_SETACCESS_SET_NAME( SetAccess, env,
>                                                                    
> text_value);
> }
> --------------------------
> Recommendation:
> --------------------------
> Do not check if the value is NULL.  Instead, just set it.  It's okay to set 
> the value to NULL in the structure.  Right now, the data is not filled in 
> because of the error being returned, so everything fails.  Should generated 
> this code instead:
> current_element = AXIOM_NODE_GET_DATA_ELEMENT( current_node, env);
> text_value = AXIOM_ELEMENT_GET_TEXT(current_element, env, current_node );
> status = AXIS2_SETACCESS_SET_NAME( SetAccess, env,
>                                                                    
> text_value);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to