(Migrated) SimpleIO Problem with input_required using JSON , XML works great!

(This message has been automatically imported from the retired mailing list)

Hello everyone,

http://pastebin.com/qis6R224

Here is a code snippet I wrote, the basics and normaly enough to raise
an exception if any of the input_required field is missing in my
request. in Json if I miss one of them nothing happen on zato side, no
Exception is raised. In Xml I’ve a Exception.

example using JSON :

request :

{
“a” : “Bonjour”,
“b”: “Erol”
}

response :

{
“response”: {
“res”: {
“a”: “Bonjour”,
“b”: “Erol”
}
}
}

Then

request :

{
“b”: “Erol”
}

Response :

{

 "response": {

     "res": {

         "a":null,

         "b":"Erol"

     }

 }

}

If I use XML request like that :

Bonjour

I have this response :

Traceback (most recent call last):
File “/home/erol/python/zato-1.1_sqlalchemy_0.9.4/zato-server/src/zato/server/connection/http_soap/channel.py”, line 157, in dispatch
self.simple_io_config, data_format, path_info)
File “/home/erol/python/zato-1.1_sqlalchemy_0.9.4/zato-server/src/zato/server/connection/http_soap/channel.py”, line 275, in handle
worker_store, cid, simple_io_config, service_info=service_info, wsgi_environ=wsgi_environ)
File “/home/erol/python/zato-1.1_sqlalchemy_0.9.4/zato-server/src/zato/server/service/init.py”, line 584, in update_handle
job_type=kwargs.get(‘job_type’))
File “/home/erol/python/zato-1.1_sqlalchemy_0.9.4/zato-server/src/zato/server/service/init.py”, line 876, in update
service._init()
File “/home/erol/python/zato-1.1_sqlalchemy_0.9.4/zato-server/src/zato/server/service/init.py”, line 563, in _init
self.request.init(self.cid, self.SimpleIO, self.data_format)
File “/home/erol/python/zato-1.1_sqlalchemy_0.9.4/zato-server/src/zato/server/service/init.py”, line 182, in init
params = self.get_params(required_list, path_prefix, default_value, use_text)
File “/home/erol/python/zato-1.1_sqlalchemy_0.9.4/zato-server/src/zato/server/service/init.py”, line 207, in get_params
raise ParsingException(self.cid, msg)
ParsingException: Caught an exception while parsing, payload:[

<![CDATA[Bonjour]]>], e:[Traceback (most recent call last):

File “/home/erol/python/zato-1.1_sqlalchemy_0.9.4/zato-server/src/zato/server/service/init.py”, line 203, in get_params
elem = path(’{}.{}’.format(path_prefix, param_name), is_required).get_from(self.payload)
File “/home/erol/python/zato-1.1_sqlalchemy_0.9.4/zato-common/src/zato/common/init.py”, line 275, in get_from
raise ParsingException(None, format_exc(e))
ParsingException: Traceback (most recent call last):
File “/home/erol/python/zato-1.1_sqlalchemy_0.9.4/zato-common/src/zato/common/init.py”, line 269, in get_from
value = _ObjectPath(_path)(elem)
File “objectpath.pxi”, line 54, in lxml.objectify.ObjectPath.call (src/lxml/lxml.objectify.c:23044)
File “objectpath.pxi”, line 218, in lxml.objectify._findObjectPath (src/lxml/lxml.objectify.c:25120)
AttributeError: no such child: b

Is it the normal behavior ? Do I have to manually check null values in my json request ?

Thanks in advance.

Erol

On 04/14/2014 02:32 PM, amaury wrote:

Hello everyone,

http://pastebin.com/qis6R224

[…]

Is it the normal behavior ? Do I have to manually check null values in
my json request ?

Hi Amaury,

you are right that the behavior should be consistent and what XML does
is correct. I will provide a fix in upcoming days.

https://github.com/zatosource/zato/issues/205

Until then you can perhaps use the ‘default_value’ parameter to make
sure an input argument has a meaningful value.

https://zato.io/docs/progguide/sio.html#anatomy-of-an-sio-service

thanks for reporting it,

On 04/14/2014 02:32 PM, amaury wrote:

Hello everyone,

http://pastebin.com/qis6R224

[…]

Is it the normal behavior ? Do I have to manually check null values in
my json request ?

Hi Amaury,

you are right that the behavior should be consistent and what XML does
is correct. I will provide a fix in upcoming days.

https://github.com/zatosource/zato/issues/205

Until then you can perhaps use the ‘default_value’ parameter to make
sure an input argument has a meaningful value.

https://zato.io/docs/progguide/sio.html#anatomy-of-an-sio-service

thanks for reporting it,