2

I am trying to make soap requests but when i use the operation.body method every array doesnt seems to be in the xml after operation.build.

Here's part of the WSDL:

<xs:element name="Item" type="ns1:TList_Item"/>
--
<xs:complexType name="TList_Item">
  <xs:complexContent>
    <xs:restriction base="soapenc:Array">
      <xs:sequence/>
      <xs:attribute xmlns:n1="http://schemas.xmlsoap.org/wsdl/" ref="soapenc:arrayType" n1:arrayType="ns1:TItem[]"/>
    </xs:restriction>
  </xs:complexContent>
</xs:complexType>
--
<xs:complexType name="TItem">
  <xs:sequence>
    <xs:element name="Item_Name" type="xs:string"/>
    <xs:element name="Item_Code" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

I tried this:

operation.body = { Item: [item1,item2,..] }

but got this error:

ArgumentError: Expected a Hash for the :Item complex type

I also tried this:

How to pass Array as parameter to SOAP in Ruby

No errors but the content never got into the xml after operation.build.

How should i approach this?

Community
  • 1
  • 1
Bernardo Mendes
  • 1,220
  • 9
  • 15

1 Answers1

1

Bernardo,

the problem here is that your WSDL is RPC/Encoded (also indicated by the "soapenc" namespace prefix on the xs:restriction base attribute) and Savon version 3 (which is not officially released yet and only available via GitHub) does not support this style yet.

RPC/Encoded is rarely used but typically found with legacy systems. It defines a whole new type system which is not implemented right now. I'm still working out a proper type system for XML Schema which is recommended for WSDL documents and that's already a lot of work. So I'm not sure when RPC/Encoded will be supported.

I would suggest you to use version 2 instead. Please make sure to follow the documentation, because version 2 works quite differently from version 3: http://savonrb.com/version2.html

Version 2 doesn't use much information from the WSDL, so you can choose to use it or not. You might need to try different options for this to work for your service (there are quite a few), but it should work.

Edit: I will change version 3 to raise an error for RPC/Encoded SOAP operations to make it obvious that this feature is currently not supported. Thank you.

rubiii
  • 6,903
  • 2
  • 38
  • 51