Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Ticket #369 (closed defect: fixed)

Opened 11 months ago

Last modified 11 months ago

nil passed as attribute to axis service gets sent as an empty string rather than nil

Reported by: user Assigned to: nahi
Priority: high Milestone: 1.5.7
Component: soap4r Version: 1.5
Keywords: nil null xsi:null Cc:

Description

As discussed here: http://groups.google.com/group/soap4r/browse_frm/thread/7dc2cde55550961b

I have created some test code. First, I built a new web service class in java with a simple method taking a single Date parameter, and returning "Date was null" if it was null, or Date.toString() if it wasn't. I exported this class as a SOAP service by adding some configuration to server-config.wsdd. I will attach the resulting wsdl file to this ticket.

I then generated a set of soap4r support files with the following command:

~/src/soap4r-1.5.6/bin/wsdl2ruby.rb --wsdl date.wsdl --type client

Conveniently for this demo, the sample DateDecoderServiceClient?.rb file is already written to call the only method defined, with a nil argument. Trying it out, with the web service running locally on tomcat, shows the bug:

~/test-soap4r $ ruby -d DateDecoderServiceClient.rb http://localhost:8080/WebService/services/date
Exception `LoadError' at /opt/local/lib/ruby/1.8/xsd/xmlparser/xmlparser.rb:10 - 
  no such file to load -- xml/parser
Exception `LoadError' at /opt/local/lib/ruby/1.8/xsd/xmlparser/xmlscanner.rb:10 - 
  no such file to load -- xmlscan/scanner
Set XSD::XMLParser::REXMLParser as XML processor.
Wire dump:

= Request

! CONNECT TO localhost:8080
! CONNECTION ESTABLISHED
POST /WebService/services/date HTTP/1.1
SOAPAction: ""
Content-Type: text/xml; charset=utf-8
User-Agent: SOAP4R/1.5.6 (/143, ruby 1.8.6 (2007-03-13) [i686-darwin8.9.1])
Date: Mon, 25 Jun 2007 09:01:28 GMT
Content-Length: 451
Host: localhost:8080

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <n1:decodeDate xmlns:n1="http://infra.helpmagic.com"
        env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <date xsi:type="xsd:dateTime"></date>
    </n1:decodeDate>
  </env:Body>
</env:Envelope>

= Response

HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Mon, 25 Jun 2007 09:01:28 GMT
Connection: close

218
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
    <soapenv:Fault>
      <faultcode>soapenv:Server.userException</faultcode>
      <faultstring>java.lang.NumberFormatException: Invalid date/time</faultstring>
      <detail>
        <ns1:hostname
         xmlns:ns1="http://xml.apache.org/axis/">localhost</ns1:hostname>
      </detail>
    </soapenv:Fault>
  </soapenv:Body>
</soapenv:Envelope>
0

! CONNECTION CLOSED


Exception `SOAP::FaultError' at /opt/local/lib/ruby/1.8/soap/rpc/proxy.rb:188 - 
  java.lang.NumberFormatException: Invalid date/time
Exception `NameError' at /opt/local/lib/ruby/1.8/soap/mapping/mapping.rb:208 - wrong constant name detail
Exception `NameError' at /opt/local/lib/ruby/1.8/soap/mapping/mapping.rb:208 - wrong constant name detail
Exception `SOAP::FaultError' at /opt/local/lib/ruby/1.8/soap/mapping/mapping.rb:118 -
  java.lang.NumberFormatException: Invalid date/time
#<SOAP::Mapping::Object:0x10d35a8>:
 java.lang.NumberFormatException: Invalid date/time (SOAP::FaultError)

(NB: I have manually re-wrapped some of the lines to make it easier to read in trac. For example, the axis soap reply originally had no line breaks.

The error is that the nil date is sent like this:

<date xsi:type="xsd:dateTime"></date>

I think it needs to be sent like this:

<date xsi:type="xsd:dateTime" xsi:null="true"></date>

but I'm not exactly sure as I don't properly know the SOAP spec. Maybe you drop the xsi:type parameter when you add the xsi:null?

Attachments

date.wsdl (2.1 kB) - added by user on 06/25/07 18:16:29.
wsdl file for my test SOAP service, generated by axis

Change History

06/25/07 18:16:29 changed by user

  • attachment date.wsdl added.

wsdl file for my test SOAP service, generated by axis

06/25/07 19:27:51 changed by nahi

  • milestone changed from undefined to 1.5.7.

06/25/07 20:38:10 changed by nahi

  • status changed from new to closed.
  • resolution set to fixed.

(In [1862]) * passing nil as a basetype through wsdl2ruby.rb generated mapping_registry was broken in 1.5.6. closes #369.