0

We having performance issues in the SOAP webservice. The webservice is built with Spyne.

I think that the problem can be solved to change the interfaces that the interfaces will only return the necessary data, because we sending large soap objects to the client.

Example:

We having a Fabric soap object with a lot of properties, see below:

class Fabric(ComplexModel):
   __namespace__ = 'vadain.webservice.curtainconfig'
   id = Mandatory.Integer
   "Fabric ID"
   articleNumber = String
   "Article Number"
   name = Mandatory.Unicode
   "Fabric Name"
   color = Mandatory.Unicode
   "Color"
   width = Float
   "Fabric Width"
   widthType = WidthType
   "Width Type"
   supplier = Mandatory.Unicode
   supplierId = Integer
   "Supplier"
   ETC.

And much more!!

We have implemented two interfaces searching fabrics and get fabric, see below:

Search fabrics:

@rpc(Unicode, _returns=soap.Fabric.customize(max_occurs='unbounded'))
def fabricsWithName(ctx, name):
--Code to get all fabrics with name
return fabrics

Get fabric:

@rpc(Integer, _returns=soap.Fabric)
def getFabric(ctx, fabric_id):
   --Code to get fabric from ID
return fabric

The interface of searing fabrics is returning all the properties of the fabrics, but this is not necessary. It can be changed that only the fabric name and id will be returned.

How can I change this in a good way that the interface 'fabricsWithName' will only return the fabric name and id and will this solve the performance issue?

Robert
  • 305
  • 1
  • 2
  • 14

1 Answers1

0

Why not set the return value to a class that only contains what you want?

e.g.

class FabricLite(ComplexModel):
   __namespace__ = 'vadain.webservice.curtainconfig'
   id = Mandatory.Integer

   name = Mandatory.Unicode

# (...)

@rpc(Integer, _returns=FabricLite)
def getFabric(ctx, fabric_id):
    # (...)

You don't need to change anything in the function body, Spyne will just ignore the rest of the data.

Also, I'd change the getFabric signature to this:

@rpc(Mandatory.UnsignedInteger32, _returns=FabricLite)

so that the incoming value validation is more strict.

Burak Arslan
  • 7,671
  • 2
  • 15
  • 24