【发布时间】:2014-04-29 12:09:07
【问题描述】:
我们在 SOAP 网络服务中遇到了性能问题。网络服务是用 Spyne 构建的。
我认为这个问题可以通过改变接口来解决,接口只会返回必要的数据,因为我们向客户端发送了大的soap对象。
例子:
我们有一个具有很多属性的织物肥皂对象,见下文:
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.
还有更多!!
我们实现了两个接口搜索fabric和getfabric,见下图:
搜索面料:
@rpc(Unicode, _returns=soap.Fabric.customize(max_occurs='unbounded'))
def fabricsWithName(ctx, name):
--Code to get all fabrics with name
return fabrics
获取面料:
@rpc(Integer, _returns=soap.Fabric)
def getFabric(ctx, fabric_id):
--Code to get fabric from ID
return fabric
灼热面料的界面正在返回面料的所有属性,但这不是必需的。可以更改为只返回结构名称和 id。
如何以一种好的方式更改此接口“fabricsWithName”将仅返回结构名称和 ID,这将解决性能问题吗?
【问题讨论】:
标签: performance soap spyne