我们在 SOAP Web 服务中遇到了性能问题。网络服务是用 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,这会解决性能问题吗?