axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Todd Doolittle (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AXIS2-1247) wsdl2java generated client throws NumberFormatException on nil integer
Date Thu, 05 Oct 2006 16:45:58 GMT
    [ http://issues.apache.org/jira/browse/AXIS2-1247?page=comments#action_12440177 ] 
            
Todd Doolittle commented on AXIS2-1247:
---------------------------------------


I just tried this with a decimal type.  The wsdl2java generated client throws a number format
exception when the decimal is returned as nil="true".  This looks related to the problems
that were resolved above for the xsd:int and xsd:date types.

Below is the exception, the service response, and the WSDL...

Exception ! java.lang.RuntimeException: java.lang.NumberFormatException
java.lang.RuntimeException: java.lang.NumberFormatException
	at org.tempuri.POCStub.fromOM(POCStub.java:2741)
	at org.tempuri.POCStub.Getinfo(POCStub.java:140)
	at POCTest.run(POCTest.java:44)
	at POCTest.main(POCTest.java:20)
Caused by: java.lang.NumberFormatException
	at java.math.BigDecimal.<init>(Unknown Source)
	at java.math.BigDecimal.<init>(Unknown Source)
	at org.apache.axis2.databinding.utils.ConverterUtil.convertToDecimal(ConverterUtil.java:230)
	at org.tempuri.POCStub$Decimal4Js$Factory.parse(POCStub.java:534)
	at org.tempuri.POCStub$Item_type0$Factory.parse(POCStub.java:2516)
	at org.tempuri.POCStub$Items_type1$Factory.parse(POCStub.java:1477)
	at org.tempuri.POCStub$GetinfoResponse$Factory.parse(POCStub.java:1920)
	at org.tempuri.POCStub.fromOM(POCStub.java:2733)
	... 3 more

Here is the response the service sent back...
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <fjs1:GetinfoResponse xmlns:fjs1="http://tempuri.org/" count="1"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <fjs1:items>
            <fjs1:item>
               <fjs1:ksn xsi:nil="true" />
               <fjs1:upc xsi:nil="true" />
               <fjs1:maintdt xsi:nil="true" />
               <fjs1:dpt>10</fjs1:dpt>
            </fjs1:item>
         </fjs1:items>
      </fjs1:GetinfoResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Here is the WSDL I used to create the client with wsdl2java...

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
   name="POC" targetNamespace="http://tempuri.org/"
   xmlns:fjs="http://tempuri.org/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <wsdl:types>
      <xsd:schema elementFormDefault="qualified"
         targetNamespace="http://tempuri.org/"
         xmlns:s1="http://tempuri.org/">

         <xsd:simpleType name="decimal4js">
            <xsd:restriction base="xsd:decimal">
               <xsd:totalDigits value="10" />
               <xsd:fractionDigits value="0" />
            </xsd:restriction>
         </xsd:simpleType>
         
         <xsd:element name="lookup">
            <xsd:complexType>
               <xsd:sequence>
                  <xsd:element maxOccurs="unbounded" minOccurs="0"
                     name="upc" nillable="true" type="xsd:string" />
               </xsd:sequence>
               <xsd:attribute name="count" type="xsd:int"
                  use="required" />
            </xsd:complexType>
         </xsd:element>
         <xsd:element name="GetinfoResponse">
            <xsd:complexType>
               <xsd:sequence>
                  <xsd:element name="items" nillable="true">
                     <xsd:complexType>
                        <xsd:sequence>
                           <xsd:element maxOccurs="unbounded"
                              minOccurs="0" name="item" nillable="true">
                              <xsd:complexType>
                                 <xsd:sequence>
                                    <xsd:element name="ksn"
                                       nillable="true" type="decimal4js" />
                                    <xsd:element name="upc"
                                       nillable="true" type="xsd:string" />
                                    <xsd:element
                                       name="maintdt" nillable="true" type="xsd:date" />
                                    <xsd:element name="dpt"
                                       nillable="true" type="xsd:int" />
                                 </xsd:sequence>
                              </xsd:complexType>
                           </xsd:element>
                        </xsd:sequence>
                     </xsd:complexType>
                  </xsd:element>
               </xsd:sequence>
               <xsd:attribute name="count" type="xsd:int"
                  use="required" />
            </xsd:complexType>
         </xsd:element>
      </xsd:schema>
   </wsdl:types>
   <wsdl:message name="GetinfoIn">
      <wsdl:part element="fjs:lookup" name="parameters" />
   </wsdl:message>
   <wsdl:message name="GetinfoOut">
      <wsdl:part element="fjs:GetinfoResponse" name="parameters" />
   </wsdl:message>
   <wsdl:portType name="POCPortType">
      <wsdl:operation name="Getinfo">
         <wsdl:input message="fjs:GetinfoIn" name="lookup" />
         <wsdl:output message="fjs:GetinfoOut"
            name="GetinfoResponse" />
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="POCBinding" type="fjs:POCPortType">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
      <wsdl:operation name="Getinfo">
         <soap:operation soapAction="getinfo" style="document" />
         <wsdl:input name="lookup">
            <soap:body use="literal" />
         </wsdl:input>
         <wsdl:output name="GetinfoResponse">
            <soap:body use="literal" />
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="POC">
      <wsdl:port binding="fjs:POCBinding" name="POCPortType">
         <soap:address
            location="http://151.149.158.136:6395/ws/r/poc" />
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>


> wsdl2java generated client throws NumberFormatException on nil integer
> ----------------------------------------------------------------------
>
>                 Key: AXIS2-1247
>                 URL: http://issues.apache.org/jira/browse/AXIS2-1247
>             Project: Apache Axis 2.0 (Axis2)
>          Issue Type: Bug
>    Affects Versions: nightly
>         Environment: Java 1.4.2, Tomcat 4, Axis 2 Nightly Build
>            Reporter: Todd Doolittle
>            Priority: Blocker
>
> I used wsdl2java to create a client based on wsdl from a non-java service.  The wsdl
specifies that one of the returned values is an integer and is nillable like this...
> <xsd:element name="ksn" nillable="true" type="xsd:int" />
> When the service returns a null/nill value it looks like this in the SOAP body:
> <fjs1:ksn xsi:nil="true"/>
> The client code throws a number format exception while processing this...
> Caused by: java.lang.NumberFormatException: For input string: ""
> 	at java.lang.NumberFormatException.forInputString(Unknown Source)
> 	at java.lang.Integer.parseInt(Unknown Source)
> 	at java.lang.Integer.parseInt(Unknown Source)
> 	at org.apache.axis2.databinding.utils.ConverterUtil.convertToInt(ConverterUtil.java:210)
> 	at org.tempuri.POCStub$Item_type0$Factory.parse(POCStub.java:2149)
> 	at org.tempuri.POCStub$Items_type1$Factory.parse(POCStub.java:1157)
> 	at org.tempuri.POCStub$GetinfoResponse$Factory.parse(POCStub.java:1593)
> 	at org.tempuri.POCStub.fromOM(POCStub.java:2330)
> 	... 3 more
> Here is the SOAP message my client sent (which looks fine):
> POST /ws/r/poc?WSDL
> HTTP/1.1
> SOAPAction: getinfo
> User-Agent: Axis2
> Host: localhost:8090
> Transfer-Encoding: chunked
> Content-Type: text/xml; charset=UTF-8
> 160
> <?xml version='1.0' encoding='UTF-8'?>
> <soapenv:Envelope
>   xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
>   <soapenv:Header />
>   <soapenv:Body>
>     <ns1:lookup xmlns:ns1="http://tempuri.org/" count="1">
>       <ns1:upc>2000000910</ns1:upc>
>       <ns1:upc
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" nil="true" />
>     </ns1:lookup>
>   </soapenv:Body>
> </soapenv:Envelope>
> 0
> Here is the non-java service's reply:
> HTTP/1.1 200 OK 
> Date: Wed, 27 Sep 2006 15:23:37 GMT
> Server: Four J's Server (Build 369)
> Content-Type: text/xml; charset="UTF-8"
> Content-Length: 532
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <SOAP-ENV:Envelope
>   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
>   <SOAP-ENV:Body>
>     <fjs1:GetinfoResponse xmlns:fjs1="http://tempuri.org/" count="1"
>       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>       <fjs1:items>
>         <fjs1:item>
>           <fjs1:ksn xsi:nil="true" />
>           <fjs1:upc>2000000910</fjs1:upc>
>           <fjs1:maintdt xsi:nil="true" />
>           <fjs1:dpt xsi:nil="true" />
>         </fjs1:item>
>       </fjs1:items>
>     </fjs1:GetinfoResponse>
>   </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> Here is the WSDL from the service...
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>   name="POC" targetNamespace="http://tempuri.org/"
>   xmlns:fjs="http://tempuri.org/"
>   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>   <wsdl:types>
>     <xsd:schema elementFormDefault="qualified"
>       targetNamespace="http://tempuri.org/"
>       xmlns:s1="http://tempuri.org/">
>       <xsd:element name="lookup">
>         <xsd:complexType>
>           <xsd:sequence>
>             <xsd:element maxOccurs="unbounded" minOccurs="0"
>               name="upc" nillable="true" type="xsd:string" />
>           </xsd:sequence>
>           <xsd:attribute name="count" type="xsd:int"
>             use="required" />
>         </xsd:complexType>
>       </xsd:element>
>       <xsd:element name="GetinfoResponse">
>         <xsd:complexType>
>           <xsd:sequence>
>             <xsd:element name="items" nillable="true">
>               <xsd:complexType>
>                 <xsd:sequence>
>                   <xsd:element maxOccurs="unbounded"
>                     minOccurs="0" name="item" nillable="true">
>                     <xsd:complexType>
>                       <xsd:sequence>
>                         <xsd:element name="ksn"
>                           nillable="true" type="xsd:int" />
>                         <xsd:element name="upc"
>                           nillable="true" type="xsd:string" />
>                         <xsd:element
>                           name="maintdt" nillable="true" type="xsd:date" />
>                         <xsd:element name="dpt"
>                           nillable="true" type="xsd:int" />
>                       </xsd:sequence>
>                     </xsd:complexType>
>                   </xsd:element>
>                 </xsd:sequence>
>               </xsd:complexType>
>             </xsd:element>
>           </xsd:sequence>
>           <xsd:attribute name="count" type="xsd:int"
>             use="required" />
>         </xsd:complexType>
>       </xsd:element>
>     </xsd:schema>
>   </wsdl:types>
>   <wsdl:message name="GetinfoIn">
>     <wsdl:part element="fjs:lookup" name="parameters" />
>   </wsdl:message>
>   <wsdl:message name="GetinfoOut">
>     <wsdl:part element="fjs:GetinfoResponse" name="parameters" />
>   </wsdl:message>
>   <wsdl:portType name="POCPortType">
>     <wsdl:operation name="Getinfo">
>       <wsdl:input message="fjs:GetinfoIn" name="lookup" />
>       <wsdl:output message="fjs:GetinfoOut"
>         name="GetinfoResponse" />
>     </wsdl:operation>
>   </wsdl:portType>
>   <wsdl:binding name="POCBinding" type="fjs:POCPortType">
>     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
>     <wsdl:operation name="Getinfo">
>       <soap:operation soapAction="getinfo" style="document" />
>       <wsdl:input name="lookup">
>         <soap:body use="literal" />
>       </wsdl:input>
>       <wsdl:output name="GetinfoResponse">
>         <soap:body use="literal" />
>       </wsdl:output>
>     </wsdl:operation>
>   </wsdl:binding>
>   <wsdl:service name="POC">
>     <wsdl:port binding="fjs:POCBinding" name="POCPortType">
>       <soap:address location="http://localhost:8090/POC/POC" />
>     </wsdl:port>
>   </wsdl:service>
> </wsdl:definitions>

-- 
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: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Mime
View raw message