You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Philemon Schucker (JIRA)" <ji...@apache.org> on 2016/04/13 13:40:25 UTC

[jira] [Created] (AXIS2-5758) wsdl2java: nillable = "true" is ignored

Philemon Schucker created AXIS2-5758:
----------------------------------------

             Summary: wsdl2java: nillable = "true" is ignored
                 Key: AXIS2-5758
                 URL: https://issues.apache.org/jira/browse/AXIS2-5758
             Project: Axis2
          Issue Type: Bug
          Components: adb
    Affects Versions: 1.7.1
            Reporter: Philemon Schucker


I tried to create a java client with wsdl2java. With version 1.7.0 and older ones everything is fine. But since version 1.7.1 the {{nillable="true"}} attribute is ignored. Here is a small example wsdl:

{code:xml}
   <definitions name="StockQuote" 
          targetNamespace="http://example.com/stockquote.wsdl"
          xmlns:tns="http://example.com/stockquote.wsdl"
          xmlns:xsd1="http://example.com/stockquote.xsd"
          xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
          xmlns="http://schemas.xmlsoap.org/wsdl/">
 
    <types>
       <schema targetNamespace="http://example.com/stockquote.xsd"
              xmlns="http://www.w3.org/2001/XMLSchema">
           <element name="TradePriceRequest">
              <complexType>
                  <all>
                      <element name="tickerSymbol" nillable="true" type="string"/>
                  </all>
              </complexType>
           </element>
           <element name="TradePrice">
              <complexType>
                  <all>
                      <element name="price" nillable="true" type="float"/>
                  </all>
              </complexType>
           </element>
       </schema>
    </types>
 
    <message name="GetLastTradePriceInput">
        <part name="body" element="xsd1:TradePriceRequest"/>
    </message>
 
    <message name="GetLastTradePriceOutput">
        <part name="body" element="xsd1:TradePrice"/>
    </message>
 
    <portType name="StockQuotePortType">
        <operation name="GetLastTradePrice">
           <input message="tns:GetLastTradePriceInput"/>
           <output message="tns:GetLastTradePriceOutput"/>
        </operation>
    </portType>
 
    <binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="GetLastTradePrice">
           <soap:operation soapAction="http://example.com/GetLastTradePrice"/>
           <input>
               <soap:body use="literal"/>
           </input>
           <output>
               <soap:body use="literal"/>
           </output>
        </operation>
    </binding>
 
    <service name="StockQuoteService">
        <documentation>My first service</documentation>
        <port name="StockQuotePort" binding="tns:StockQuoteSoapBinding">
           <soap:address location="http://example.com/stockquote"/>
        </port>
    </service>
 
 </definitions>
{code}

For creating the client I use the {{-u}} option. The problem appears in the Factory's parse method for the defined types. For example for TradePrice.java from the given wsdl above:

Genereated code from version 1.7.0 (snippet from Factory parse method):
{code:title=TradePrice.java|borderStyle=solid}
if (!"true".equals(nillableValue) &&
        !"1".equals(nillableValue)) {
    java.lang.String content = reader.getElementText();

             object.setPrice(org.apache.axis2.databinding.utils.ConverterUtil.convertToFloat(
            content));
} else {
    object.setPrice(java.lang.Float.NaN);

    reader.getElementText(); // throw away text nodes if any.
}
{code}


Genereated code from version 1.7.1 (snippet from Factory parse method):
{code:title=TradePrice.java|borderStyle=solid}
if ("true".equals(nillableValue) ||
    "1".equals(nillableValue)) {
    throw new org.apache.axis2.databinding.ADBException(
        "The element: " + "price" +
        "  cannot be null");
}

java.lang.String content = reader.getElementText();

object.setPrice(org.apache.axis2.databinding.utils.ConverterUtil.convertToFloat(
    content));
{code}

So as you can see, in 1.7.1 the {{price}} element is handled as a non nillable value although it is nillable. So if the server sends a repsonse with price = null the client will throw an exception although everything is fine...



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org