0

I'm using suds 0.4

I'm trying to create a node like this (from example SOAP request):

<id xsi:type="xs:int">123456</id>

It is a parameter of a SOAP call and merely passing an int generates this:

<int>123456</int>

which gives me

Expected: class java.lang.Integer, got class org.apache.xerces.dom.ElementNSImpl

So what I need is a way of creating the right type. I've tried creating an instance of xsd:int which works but then there is no way I can see of setting the value.

Anyone got any ideas?

EDIT

Code:

findResult = self.client.service.find(self._getSession(), 'Candidate', 123456)

or

find = self.client.factory.create('find')
find.session = self._getSession()
find.entityName = 'Candidate'
find.id = 123456
findResult = self.client.service.find(find)

Same result both times. It seems that it passes the id as text field. I've checked the type and I am definitely using an int type. In the WSDL schema the parameter type is:

<xs:complexType name="find">
  <xs:sequence>
    <xs:element name="session" type="xs:string" minOccurs="0"/>
    <xs:element name="entityName" type="xs:string" minOccurs="0"/>
    <xs:element name="id" type="xs:anyType" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>

Id anyType the problem here?

Robin Elvin
  • 1,207
  • 12
  • 28

1 Answers1

0

I had "similar" problem, where i needed a value to have an xsi:type="xsd:int" ( Suds write request missing datatype? ) and for some reason this was not added to the xml

I eventually stumbled across this Adding xsi:type and envelope namespace when using SUDS and adapted the solution there for my usage, basically a Suds plugin "rewriting" my Value element to include the xsi:type="xsd:int" attribute.

It might be that you can use similar approach to set a type on your outgoing SOAP.

Also a suggestion, might be that you know it, to output the SOAP:

import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
Community
  • 1
  • 1
takilara
  • 108
  • 6
  • This is in fact what I ended up doing but it seemed messy as at the least it processes all nodes each time. – Robin Elvin Dec 04 '12 at 11:36
  • Yes i agree it is messy. I am fairly sure there must be other ways to do it that is better, but eventually i gave up and went with the way that worked.. – takilara Dec 04 '12 at 18:54