I'm using the Savon gem with Ruby to post requests to a wsdl webservice. The problem is that, when i send the request, the response shows me that the response is OK, but it's lacking one item I send in the request, with the help of the development team, i can see that the webservice gets the request without the item, so i can think that I'm doing something wrong with the request format or data, Because i'm using Savon 2 stable I can't see the request xml Savon send directly.
The item is the last one, the "promotion_rules" one.
@result = @client.call(
:create_template, message: {
:item => [{
'promotion_id' => 1,
'initial_quantity' => 0,
:products => [{
:product => {
'id' => 3,
'quantity' => 1
}
}],
:lists => [{
:list => [
0,
1,
2
]
}],
:promotion_rules => [{
:promotion_rule => {
'code' => "NEW_USER",
'value' => 1
}
}]
}]
}
)
The response i get is:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.test.enterprise.com">
<SOAP-ENV:Body>
<ns1:createTemplateResponse>
<item>
<response>
<code>000</code>
<description>Aprobada</description>
<ticket>99999999</ticket>
</response>
<attention>
<begin>2016-12-23 10:49:50</begin>
<end>2016-12-23 10:49:50</end>
<time>0.2</time>
</attention>
<template_id>901</template_id>
</item>
</ns1:createTemplateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The specific data that is required in that items is the following:
<xsd:element name="promotion_rules" maxOccurs="1" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="promotion_rule" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="code" type="xsd:string"/>
<xsd:element name="value" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Thank you in advance.
The problem was found in the way the arrays and element where specified, instead of :element it should be 'element':
Instead of: