网络通信 频道

WSE2.0变化 自适应网络服务时代到来

  WSE2.0立足网络服务宗旨,支持WS-Addressing

  微软在开发网络服务增强服务WSE 2.0 中的一个最基本的更改是放弃了对 WS-Routing 的支持,并添加了对 WS-Addressing 的支持。WSE 2.0 在 Microsoft.Web.Services.Addressing 命名空间中为 WS-Addressing 提供了多个新类。整个消息 API 已经重新设计为围绕终结点引用,而不是 URI。WSE 2.0 引入了一个名为 EndpointReference 的新类,这个类在整个 WSE 2.0 API 中替换了 System.Uri。例如,SoapSender 和 SoapReceiver 类现在直接处理 EndpointReference 对象。下面的代码片段模拟了在一个基于 TCP 的简单聊天应用程序中如何利用 SoapSender 类来使用 EndpointReference 对象:
  ...
  SoapEnvelope env = new SoapEnvelope();
  env.Context.Addressing.Action = String.Format("urn:chat:message");
  EndpointReference epr =
  new EndpointReference("soap.tcp://askonnard:123/aaron"));
  env.Context.Addressing.ReplyTo = new ReplyTo(epr);
  env.CreateBody(); // must create body before setting it
  env.Body.InnerXml = String.Format(
  "<x:message xmlns:x=''urn:chat''><user>{0}</user><msg>{1}</msg>
  </x:message>", user, msg);
  ...
  EndpointReference epr = new EndpointReference(
  new Uri("soap.tcp://askonnard:456/monica"));
  SoapSender ss = new SoapSender(epr);
  ss.Send(env);
  ...
  一旦使用 WSE 2.0 发送消息,WSE 2.0 就会自动添加必需的 WS-Addressing 消息信息标头。

0
相关文章