是否可以在不定义消息合同的情况下添加mtom以及其他成员? [英] mtom plus further members possible without defining message contract?

查看:62
本文介绍了是否可以在不定义消息合同的情况下添加mtom以及其他成员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了从使用者那里获得的其他参数外,我还有一个接受MTOM流的服务.

我看到的启用此功能的唯一方法是在服务接口中定义消息协定,例如为:

[ MessageContract ]

公共 class UploadPackage

{

[ MessageHeader ]

公共 字符串 舰队;

[ MessageHeader ]

公共 字符串 unitNumber;

[ MessageHeader ]

公共 字符串 dateTime;

[ MessageBodyMember ]

public Stream eventStream;

}


我已经在很多地方读过书(我也知道我自己),所以最好尽可能避免签订消息合同.是否可以在不使用显式消息协定定义的情况下启用MTOM以及进一步的参数请求?

解决方案

将Stream与MTOM一起使用(并获得将其流优化为MTOM附件的好处),那么Stream必须是消息正文中的唯一参数,因此,如果需要,消息契约是唯一的解决方法.如果您不使用流,则只需将所有参数放入操作协定中,就不会有什么问题.


I have a service that accepts an MTOM stream in addition to other parameters from the consumer.

The only way I can see of enabling this is to define a message contract in the service interface such as:

[MessageContract]

public class UploadPackage

{

[MessageHeader]

public string fleet;

[MessageHeader]

public string unitNumber;

[MessageHeader]

public string dateTime;

[MessageBodyMember]

public Stream eventStream;

}


I've read in several places (and I know myself) it's better to avoid message contracts whenever possible. Is there a way of enabling MTOM plus further parameter request without using explicit message contract definition?

解决方案

If you want to use Stream with MTOM (and get the benefit of having that stream be optimized as a MTOM attachment), then the Stream has to be the only parameter in the message body, so message contract is the only way to go if you need that. If you are not using streams, then you can simply put all parameters in the operation contract, that shouldn't be any problem.


这篇关于是否可以在不定义消息合同的情况下添加mtom以及其他成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆