J
Justin Zipperle
Hi all-
I'm building an app using soap4r v1.5.8 and I've generated client stubs
using wsdl2ruby. I can retrieve a complex object but when I try to
'put' the same object I get an error from the API:
"Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found
starting with element 'n3:logicalOperation'. One of
'{"http://www.strongmail.com/services/2009/03/02/schema":condition}' is
expected."
When I examine the raw XML I see differences in the structure where the
error is being reported. Here is the part of the XML returned for a
'get' operation:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getResponse
xmlns="http://www.strongmail.com/services/2009/03/02/schema">
<success>true</success>
<fault xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true" />
<getResponse>
<baseObject
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Rule">
<!-- snip -->
<ifPart>
<condition1>
<column>table.code</column>
<op>EQUALS</op>
<value>IC</value>
</condition1>
<logicalOperation>AND</logicalOperation>
<condition>
<column>table.level</column>
<op>NOT_ONE_OF</op>
<value>gold,platinum</value>
</condition>
<logicalOperation>OR</logicalOperation>
<condition>
<column>table.level</column>
<op>EQUALS</op>
<value>none</value>
</condition>
</ifPart>
<!-- snip -->
</baseObject>
</getResponse>
</getResponse>
</soap:Body>
</soap:Envelope>
And here's the XML generated by soap4r for the corresponding 'put'
request to the same API:
<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>
<n3:create
xmlns:n3="http://www.strongmail.com/services/2009/03/02/schema">
<n3:baseObject xsi:type="n3:Rule">
<!-- snip -->
<n3:ifPart>
<n3:condition1>
<n3:column>table.code</n3:column>
<n3p>EQUALS</n3p>
<n3:value>IC</n3:value>
</n3:condition1>
<n3:logicalOperation>AND</n3:logicalOperation>
<n3:logicalOperation>OR</n3:logicalOperation> <!-- TOO SOON
-->
<n3:condition> <!-- TOO LATE -->
<n3:column>table.level</n3:column>
<n3p>NOT_ONE_OF</n3p>
<n3:value>gold,platinum</n3:value>
</n3:condition>
<n3:condition>
<n3:column>table.level</n3:column>
<n3p>EQUALS</n3p>
<n3:value>none</n3:value>
</n3:condition>
</n3:ifPart>
<!-- snip -->
</n3:baseObject>
</n3:create>
</env:Body>
</env:Envelope>
I create this request using the same Ruby object created by the original
response. I would expect soap4r to generate identical XML for the
object, but notice how the ordering of elements differs - it should be
"condition1, logicalOperation(AND), condition, logicalOperation(OR),
condition".
When I inspect the Ruby object I see that logicalOperation and condition
are both Arrays containing the original values in the right order. I
assume this is a correct transformation from the original XML using the
XSD/WSDL... I'm hoping someone here knows more about the inner workings
of soap4r and can help me find a workaround.
Here's the relevant section from the XSD:
<xs:complexType name="RuleIfPart">
<xs:sequence>
<xs:element name="condition1" type="tns:RuleIfPartCondition"/>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="logicalOperation"
type="tns:LogicalOperation"/>
<xs:element name="condition" type="tns:RuleIfPartCondition"/>
</xs:sequence>
</xs:sequence>
</xs:complexType>
And here's the class generated by wsdl2ruby:
# {http://www.strongmail.com/services/2009/03/02/schema}RuleIfPart
# condition1 - RuleIfPartCondition
# logicalOperation - LogicalOperation
# condition - RuleIfPartCondition
class RuleIfPart
attr_accessor :condition1
attr_accessor :logicalOperation
attr_accessor :condition
def initialize(condition1 = nil, logicalOperation = [], condition =
[])
@condition1 = condition1
@logicalOperation = logicalOperation
@condition = condition
end
end
The full WSDL and XSD are more than 4k lines - I can send them directly
if someone wants to peel them apart. Any thoughts on how I can
workaround this issue?
Many thanks in advance!
-Justin
I'm building an app using soap4r v1.5.8 and I've generated client stubs
using wsdl2ruby. I can retrieve a complex object but when I try to
'put' the same object I get an error from the API:
"Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found
starting with element 'n3:logicalOperation'. One of
'{"http://www.strongmail.com/services/2009/03/02/schema":condition}' is
expected."
When I examine the raw XML I see differences in the structure where the
error is being reported. Here is the part of the XML returned for a
'get' operation:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getResponse
xmlns="http://www.strongmail.com/services/2009/03/02/schema">
<success>true</success>
<fault xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:nil="true" />
<getResponse>
<baseObject
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Rule">
<!-- snip -->
<ifPart>
<condition1>
<column>table.code</column>
<op>EQUALS</op>
<value>IC</value>
</condition1>
<logicalOperation>AND</logicalOperation>
<condition>
<column>table.level</column>
<op>NOT_ONE_OF</op>
<value>gold,platinum</value>
</condition>
<logicalOperation>OR</logicalOperation>
<condition>
<column>table.level</column>
<op>EQUALS</op>
<value>none</value>
</condition>
</ifPart>
<!-- snip -->
</baseObject>
</getResponse>
</getResponse>
</soap:Body>
</soap:Envelope>
And here's the XML generated by soap4r for the corresponding 'put'
request to the same API:
<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>
<n3:create
xmlns:n3="http://www.strongmail.com/services/2009/03/02/schema">
<n3:baseObject xsi:type="n3:Rule">
<!-- snip -->
<n3:ifPart>
<n3:condition1>
<n3:column>table.code</n3:column>
<n3p>EQUALS</n3p>
<n3:value>IC</n3:value>
</n3:condition1>
<n3:logicalOperation>AND</n3:logicalOperation>
<n3:logicalOperation>OR</n3:logicalOperation> <!-- TOO SOON
-->
<n3:condition> <!-- TOO LATE -->
<n3:column>table.level</n3:column>
<n3p>NOT_ONE_OF</n3p>
<n3:value>gold,platinum</n3:value>
</n3:condition>
<n3:condition>
<n3:column>table.level</n3:column>
<n3p>EQUALS</n3p>
<n3:value>none</n3:value>
</n3:condition>
</n3:ifPart>
<!-- snip -->
</n3:baseObject>
</n3:create>
</env:Body>
</env:Envelope>
I create this request using the same Ruby object created by the original
response. I would expect soap4r to generate identical XML for the
object, but notice how the ordering of elements differs - it should be
"condition1, logicalOperation(AND), condition, logicalOperation(OR),
condition".
When I inspect the Ruby object I see that logicalOperation and condition
are both Arrays containing the original values in the right order. I
assume this is a correct transformation from the original XML using the
XSD/WSDL... I'm hoping someone here knows more about the inner workings
of soap4r and can help me find a workaround.
Here's the relevant section from the XSD:
<xs:complexType name="RuleIfPart">
<xs:sequence>
<xs:element name="condition1" type="tns:RuleIfPartCondition"/>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="logicalOperation"
type="tns:LogicalOperation"/>
<xs:element name="condition" type="tns:RuleIfPartCondition"/>
</xs:sequence>
</xs:sequence>
</xs:complexType>
And here's the class generated by wsdl2ruby:
# {http://www.strongmail.com/services/2009/03/02/schema}RuleIfPart
# condition1 - RuleIfPartCondition
# logicalOperation - LogicalOperation
# condition - RuleIfPartCondition
class RuleIfPart
attr_accessor :condition1
attr_accessor :logicalOperation
attr_accessor :condition
def initialize(condition1 = nil, logicalOperation = [], condition =
[])
@condition1 = condition1
@logicalOperation = logicalOperation
@condition = condition
end
end
The full WSDL and XSD are more than 4k lines - I can send them directly
if someone wants to peel them apart. Any thoughts on how I can
workaround this issue?
Many thanks in advance!
-Justin