使用WCF按照行业标准实现服务?

发布于 2024-08-23 08:05:00 字数 874 浏览 3 评论 0原文

我正在寻找一个合适的框架来实现 .NET 中的(Web)服务层。我对 WCF 有点熟悉,想知道它是否可以按照我想要的方式定制。

1)系统发送/接收的消息有一个行业标准,它定义了操作、使用的类型等。它是基于XML的。它要求所有的请求/响应都被包裹在一个信封中,例如:

<xxx:Message>
  <xxx:Header>
    //some header data
  </xxx:Header>
  <xxx:Body>
    <xxx:Command>
      //request data
    </xxx:Command>
    <xxx:Command>
      //request data
    </xxx:Command>
  <xxx:Body>
</xxx:Message> 

xxx:Command元素实际上标识了要执行的操作和参数,或者包含了命令执行结果。
WCF 将所有内容包装到 SOAP 信封中。是否可以将其定制为使用上面示例中的信封而不是 SOAP 来发送所有请求?我应该如何对我的服务进行编码,以便正确解析所有传出和传入的消息。我应该查看 [MessageContract][DataContract] 属性还是两者都查看?

2)单向操作。行业标准规定,服务应使用“确认”消息进行响应,表明已收到请求。我正在研究实现类似方法的单向操作 - 一旦服务器收到消息,它们就会通知客户端。我想知道如何自定义发送的“确认”消息以符合行业标准。

如果 WCF 不允许这样做,您能否将我转发给任何其他可能的解决方案 - 远程处理,也许其他一些 Web 服务库?

I am looking for a proper framework to implement the (web)service tier in .NET. I am a little bit familiar with WCF and wondering, if it can be customized the way I want it.

1)There is an industry standard for messages to be sent/recieved by the system, which defines the operations, types used, etc. It is XML based. It requires all requests/responses to be wrapped in an envelope, e.g.:

<xxx:Message>
  <xxx:Header>
    //some header data
  </xxx:Header>
  <xxx:Body>
    <xxx:Command>
      //request data
    </xxx:Command>
    <xxx:Command>
      //request data
    </xxx:Command>
  <xxx:Body>
</xxx:Message> 

The xxx:Command element actually identifies the operation to be performed and parameters, or contains the command execution result.
The WCF wraps everything to SOAP envelope. Can it be customized to send all requests using the envelope in the sample above, instead of SOAP? How should I code my services, so that all outgoing and incoming messages are parsed correctly. Should I look to [MessageContract] or [DataContract] attributes or both?

2)One-way operations. The industry standard states that the services should respond with the "acknowledgment" message, that the request has been received. I was looking at the one-way operations, that implement the similar approach - they notify the client as soon as the message is received by the server. I am wondering, how can I customize the "acknowledgment" message being sent to conform to the industry standard.

If WCF does not allow that, can you forward me to any other possible solution out there - Remoting, maybe some other web-services libraries?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

病女 2024-08-30 08:05:00

1)这两个属性都不会帮助你。这些属性由绑定(例如,WS-HttpBinding)解释以确定如何实际创建消息。您将必须编写一个自定义绑定来执行此操作,并且可能需要编写一个自定义序列化程序,具体取决于“请求数据”字段的结构。

2)同样,您将需要编写自定义绑定。

快速搜索没有显示 WCF 的 GSA S2S 绑定的任何现有实现。

现有 S2S 引擎(例如 S2SConnect )。许可成本可能值得也可能不值得因开发自己的实施而节省的时间。

1) Neither attribute will help you. Those attributes are interpreted by the binding (e.g., WS-HttpBinding) to determine how to actually create your messages. You're going to have to write a custom binding to do this, and possibly a custom serializer depending on how "request data" fields are structured.

2) Again, you're going to need to write a custom binding.

A quick search didn't show any existing implementations of a GSA S2S binding for WCF.

There are existing engines for S2S (for example S2SConnect). The licensing costs may or may not be worth the time savings from having to develop your own implementation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文