Question: savon gem SOAP-ERROR: Encoding: Violation of encoding rules

Question

savon gem SOAP-ERROR: Encoding: Violation of encoding rules

Answers 1
Added at 2016-12-27 16:12
Tags
Question

I am using savon version-2 gem for soap requests, and for authorization and few other urls I didn't face problem, but for particular endpoint I need to search the date range from and to which needs to be passed inside item so the problem is first item get replaced by second how do i avoid this

client = Savon.client(wsdl: "http://www.sss.ss/api/v2_soap/?wsdl", log_level: :debug, pretty_print_xml: true, log: true)
session = client.call(:login, message: {username: 'sss', apiKey: 'sss'})
result = client.call(:sales_order_list, message: {sessionId: session.body[:login_response][:login_return], filters: {filter: {item: {key: 'created_at', value: {key: 'from', value: '2016-12-27 00:00:00'}}, item: {key: 'created_at', value: {key: 'to', value: '2016-12-27 23:59:59'}} }}})

the xml generated is like with the to value only and i get the error:

SOAP-ERROR: Encoding: Violation of encoding rules

I think overwriting items is the problem How do i send 2 items inside filter

Answers
nr: #1 dodano: 2016-12-28 07:12

I had a couple of problems with my xml, the filter inside the filters is wrong, inside filters i needed to have complex_filter and also while generating camel_case turned to camelCase which showed http 500 error.

For generating arrays of items i followed a comment from this answer How to generate repeating xml elements in Savon?

This link i followed https://github.com/savonrb/gyoku/blob/master/spec/gyoku/hash_spec.rb

Source Show
◀ Wstecz