Open RKrahl opened 2 years ago
Update: apparently, this is triggered by a bug in suds-jurko. You may skip to the conclusion below. :smile:
Debugging the situation sketched above:
>>> dc = client.new("dataCollection")
>>> dc.create()
Traceback (most recent call last):
...
icat.exception.ICATInternalError: INTERNAL org.icatproject.core.IcatException
Looking at the SOAP message that the client sends to the server:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://icatproject.org" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:create>
<sessionId>b514b463-e45b-4317-bcf7-1502d7a702dc</sessionId>
</ns0:create>
</ns1:Body>
</SOAP-ENV:Envelope>
This is clearly broken.
Trying a variant, it works:
>>> dc = client.new("dataCollection", id=0)
>>> dc.create()
>>> dc.id
28
The SOAP message now looks like:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://icatproject.org" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:create>
<sessionId>b514b463-e45b-4317-bcf7-1502d7a702dc</sessionId>
<bean xsi:type="ns0:dataCollection">
<id>0</id>
</bean>
</ns0:create>
</ns1:Body>
</SOAP-ENV:Envelope>
Trying the first version using suds-community works:
>>> dc = client.new("dataCollection")
>>> dc.create()
>>> dc.id
27
The SOAP message that suds-community sends to the server looks like:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://icatproject.org" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:create>
<sessionId>69a36d8a-41ec-4beb-85b2-377ed8badf96</sessionId>
<bean xsi:type="ns0:dataCollection"/>
</ns0:create>
</ns1:Body>
</SOAP-ENV:Envelope>
The issue is triggered by a bug in suds-jurko. Both suds versions leave out unset attributes when sending the SOAP message to the server, which is correct. But suds-jurko leaves out the entire bean
element when no attribute is set at all, which is completely broken.
Nevertheless, I still maintain that this is also a bug in icat.server: it should reply either with a ParameterError
or a ValidationError
instead of an InternalError
. A NullPointerException
should not happen, regardless how defective the client input is.
Creating an empty
DataCollection
having no content and no attributes set causes aNullPointerException
inicat.server
:The relevant bits of the icat.log: