I'm using soap4r-1.5.6.
I have a method in a java class which is made available over SOAP
using Apache Axis. The method signature is:
public CallInfo[] getCallInfosWithStatus(final int userRef, final Date
startDate, final Date endDate, final boolean open) throws
RemoteException
The java method is written so that if null is passed for endDate, the
current date is selected (actually, it uses a different SQL
statement).
When I call the function from ruby, it seems to pass an empty string
instead of labelling the value xsi:null="true" which is what I think
is supposed to happen. This causes some java code deep within axis to
complain that I haven't passed a valid date/time. Here is some test
code I'm using, followed by a debug log:
endpoint_url = ARGV.shift
obj = Connection.new(endpoint_url)
# run ruby with -d to see SOAP wiredumps.
obj.wiredump_dev = STDERR if $DEBUG
user_id=1
start_date = Time.now - (60 * 60 * 24 * 7 * 4 * 3)
end_date = nil
open = false
calls = obj.getCallInfosWithStatus(user_id, start_date, end_date,
open)
= Request
! CONNECT TO 0.0.0.0:8080
! CONNECTION ESTABLISHED
POST /WebService/services/main 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: Fri, 22 Jun 2007 10:06:13 GMT
Content-Length: 661
Host: 0.0.0.0: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:getCallInfosWithStatus xmlns:n1="http://example.com"
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<userRef xsi:type="xsd:int">1</userRef>
<startDate
xsi:type="xsd:dateTime">2007-03-30T11:06:13.820083+01:00</startDate>
<endDate xsi:type="xsd:dateTime"></endDate>
<open xsi:type="xsd:boolean">false</open>
</n1:getCallInfosWithStatus>
</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: Fri, 22 Jun 2007 10:06:15 GMT
Connection: close
207
<?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/">example</ns1:hostname></detail></soapenv:Fault></
soapenv:Body></soapenv:Envelope>
0
! CONNECTION CLOSED
So, the parameter passed is:
<endDate xsi:type="xsd:dateTime"></endDate>
Should it have been this instead?
<endDate xsi:type="xsd:dateTime" xsi:null="true" />
If so, is the mistake in the wsdl file exported by axis, axis code
(I'm using v1.4), my code, or soap4r?
Thanks
Jon
Passing nil means omitting the XML element completely. That is
something different than passing an empty string (XML element with no
value). You seem to need to pass SOAP::SOAPNil.new instead of plain
nil - see http://dev.ctor.org/soap4r/ticket/343
Leoš Bitto
On Jun 22, 12:08 pm, Leoš Bitto <Leos.Bi...@gmail.com> wrote:
> Passing nil means omitting the XML element completely. That is
> something different than passing an empty string (XML element with no
> value). You seem to need to pass SOAP::SOAPNil.new instead of plain
> nil - seehttp://dev.ctor.org/soap4r/ticket/343
Thanks very much for the link. Passing SOAPNil.new instead of nil
makes my function call work.
However, passing nil doesn't omit the element, like you specified. It
was passing an empty element instead.
It looks like I need to change my wsdl so that minOccurs="0" for that
date element. Problem is my wsdl file is automatically generated by
axis from a wsdd file. I don't suppose you know what to do in that
case? I've searched around the axis website with google and I can't
find anything.
This is an extract from the current wsdl:
<wsdl:message name="getCallInfosWithStatusRequest">
<wsdl:part name="userRef" type="xsd:int"/>
<wsdl:part name="startDate" type="xsd:dateTime"/>
<wsdl:part name="endDate" type="xsd:dateTime"/>
<wsdl:part name="open" type="xsd:boolean"/>
</wsdl:message>
Jon
Yes, you are right. SOAP4R omits the element only when it can safely
be omitted - that means if it is described as minOccurs="0".
> Problem is my wsdl file is automatically generated by
> axis from a wsdd file. I don't suppose you know what to do in that
> case?
Sorry, I am not an Axis guru... However, you should know whether you
want to allow omitting of some elements in your service or not. If you
want to allow omitting them, they should be described as
minOccurs="0". If you do not want to allow omitting them, they must
not be described as minOccurs="0". This way you should not have any
problems, I hope.
Leoš Bitto
Hi,
Jon Evans wrote:
> However, passing nil doesn't omit the element, like you specified. It
> was passing an empty element instead.
It should be a bug. For literal service, passing nil should generate
xsi:nil=true or should not generate any element. Would you please file
a ticket? http://dev.ctor.org/soap4r/wiki#BugreportorFeaturerequest
Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
iQEVAwUBRnvggx9L2jg5EEGlAQIlwAgAtXGup9LqSHg6gXSKqQZKY7WkyFaaMmQf
U9RUcP9G4MVlY8w6jsCl5HTxYcBZWXXgw3o+9fI71YqUq37GDP4qae/RQzmJ2b5C
NGOkBbiRuqvP3XTCI0g84XZKwEtXjTIr+XQHjQUkDw9ihxjy515djBIz5WO7D9Xu
rFKggr8J6Nfm82dJb+x4KiYEJvnrMLOA95lrLztNagmAWpFp6/7/OihINIEndEQg
aL3S14xWmuQzUEytJxT01Lyxc+59K55sbQQ0yjV53bW6fDZ4EEyKmv1MvnDY9L6Q
3cmWrjfCR/RdiCumpUTH3FJMPpe92fJcvkgA/tP+6Xp6lcKduy7fVA==
=p5O6
-----END PGP SIGNATURE-----
> Jon Evans wrote:
> > However, passing nil doesn't omit the element, like you specified. It
> > was passing an empty element instead.
>
> It should be a bug. For literal service, passing nil should generate
> xsi:nil=true or should not generate any element. Would you please file
> a ticket? http://dev.ctor.org/soap4r/wiki#BugreportorFeaturerequest
>
> Regards,
> // NaHi
Let me quote your comment from http://dev.ctor.org/soap4r/ticket/343 :
for literal service, let LiteralRegistry treat nil parameter as same
as WSDLLiteralRegistry. omit element if minOccurs == '0' and otherwise
add xsi:nil="true"
So is it really a bug?
Leoš
Hi,
Leoš Bitto wrote:
>>> However, passing nil doesn't omit the element, like you specified. It
>>> was passing an empty element instead.
>> It should be a bug. For literal service, passing nil should generate
>> xsi:nil=true or should not generate any element. Would you please file
>> a ticket? http://dev.ctor.org/soap4r/wiki#BugreportorFeaturerequest
> Let me quote your comment from http://dev.ctor.org/soap4r/ticket/343 :
>
> for literal service, let LiteralRegistry treat nil parameter as same
> as WSDLLiteralRegistry. omit element if minOccurs == '0' and otherwise
> add xsi:nil="true"
>
> So is it really a bug?
I meant that nil should be treated for literal service:
minOccurs == '0' ('1' by default) --> omit element
otherwise --------------------------> <ele xsi:nil="true"/>
But the current behavior for Jon is:
minOccurs == '0' ('1' by default) --> omit element
otherwise --------------------------> <ele/> # no xsi:nil="true" here
So I thought it was a bug.
BUT
I found that it's a different problem. <wsdl:part> does not take
neither minOccurs nor nillable attribute. It's not an XML Schema problem...
Maybe it's an rpc/literal service I think. Jon, can you show me a
concrete WSDL file? I need to write a test first then I'll fix the
problem. You should be able to pass an argument nil to send
xsi:nil="true" element.
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
iQEVAwUBRnzqex9L2jg5EEGlAQJuWAgAg+R6+5ThjjQ5Vn/ozEeu5wUdvQBAxDVz
ZeOc1TWsBE6mkz+ohstsZQ71+IT5M86Z8Muyax9G4UTj4KSc6HGt7Sh+WUOBIpcC
DT0uuv9DEqEm0qP5kgWUjRXoai4QxraZNz4clscr1vGz1zHRxsNP/4UQs2oKBxMU
ngwXcAu5Yn8PPqfXTMvkibdwZis58IRP4EjcQS6cWmdHS++1qeWfmlpsscmLDenI
1H1KhVDdKsq3dRs/xuaxRu9CtMJHHNavEm749F+n6UTVmNFvNJfmhVhPp+LOsm0I
ALt0i5xx+D+qlBqpdcKlPmQ8UxeROrbBePfsRv1AtREVbI1cFpAOpg==
=2use
-----END PGP SIGNATURE-----
On Jun 23, 10:40 am, "NAKAMURA, Hiroshi" <nakah...@sarion.co.jp>
wrote:
> So I thought it was a bug.
>
> BUT
>
> I found that it's a different problem. <wsdl:part> does not take
> neither minOccurs nor nillable attribute. It's not an XML Schema problem...
>
> Maybe it's an rpc/literal service I think. Jon, can you show me a
> concrete WSDL file? I need to write a test first then I'll fix the
> problem. You should be able to pass an argument nil to send
> xsi:nil="true" element.
I have logged a ticket on the soap4r trac:
http://dev.ctor.org/soap4r/ticket/369
I attached a sample wsdl file to the ticket. If you need me to attach
a war file containing the java code to test against then let me know.
Thanks
Jon
Hi,
Jon Evans wrote:
> I have logged a ticket on the soap4r trac:
>
> http://dev.ctor.org/soap4r/ticket/369
>
> I attached a sample wsdl file to the ticket. If you need me to attach
> a war file containing the java code to test against then let me know.
Thanks! Attached is a patch for fixing the xsi:nil problem. I'll
include this fix to 1.5.7 (I'm planning to release 1.5.7 in a month).
It's just a regression problem while refactoring I did in 1.5.6, not an
rpc/literal thing.
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
iQEVAwUBRn+e2h9L2jg5EEGlAQL8Zwf/cRaT0Js5xNIysH3ISbDgF4LkTRhVoNRn
7tSqiPBDNTpDMkwwwu4G2lvMxnOtaEl2Nf3t8+ncD0uA3CxqJ5+eFKkrYaoPGZuL
UGbQ8jg8Oj/F95eRo6iCYd2BeSd3udHGZSVR5RPATkdQ4Ox7MLZRNcQwMc2bXQle
+1/T6mRJ7NLPT5U00hXxHYW5h/W9dGREESMD8oQn4QRPeo3JHeruzEUVaf7w/FHl
/iy/I0kx7HAXruGJWrNhNKgp2VqgRCNneWYd4Dsy3J6Hs5HSkSEDMnywqHeAtT6g
D3v7vy01COos0HoFy85wh80/Q7hc1woKEBK2tTZE6DvyRdRZiHVveg==
=D6jP
-----END PGP SIGNATURE-----
On Jun 25, 11:54 am, "NAKAMURA, Hiroshi" <nakah...@sarion.co.jp>
wrote:
> Thanks! Attached is a patch for fixing the xsi:nil problem. I'll
> include this fix to 1.5.7 (I'm planning to release 1.5.7 in a month).
>
> It's just a regression problem while refactoring I did in 1.5.6, not an
> rpc/literal thing.
Thanks for the really quick fix! My code is working fine now with this
patch applied.
Jon