我可以将 WCF wsHttpContextBinding 与 WSIT (Metro) 客户端一起使用吗?

发布于 2024-10-25 10:07:38 字数 1142 浏览 2 评论 0原文

我正在开发 WCF - WSIT (Metro) 集成项目,我希望允许 Java 客户端连接到持久服务。

持久的服务 http://msdn.microsoft.com/en- us/library/bb410767(v=vs.90).aspx

持久服务需要 wsHttpContextBinding,这似乎工作正常。唯一的问题是 WSIT 客户端生成的代理似乎无法将instanceId 分配给soap 信封。是否有我不知道的配置设置,或者可能有一种拦截传出消息并附加 instanceId 的方法?

以下 SOAP 示例由 .NET 客户端生成。信封 WSIT 发送与此发送之间的唯一区别是 WSIT 发送中缺少 Context 节点:

      <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:r="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:a="http://www.w3.org/2005/08/addressing">
        <s:Header> 
...
          <Context xmlns="http://schemas.microsoft.com/ws/2006/05/context">
            <Property name="instanceId">{I want to set this Id}</Property>
          </Context>
...
        </s:Header>
        <s:Body>
          <IncreaseCounter xmlns="http://tempuri.org/"/>
        </s:Body>
      </s:Envelope>

我希望这是有意义的。问题不是ws2007HttpBinding或wsHttpBinding相关或WCF实例管理相关之类;每次/呼叫、会话、单个。我需要 WSIT 方面的帮助,仅涉及 Java 部分。

I am working on a WCF - WSIT (Metro) integration project and I would like to allow Java clients to connect to Durable Services.

Durable Services
http://msdn.microsoft.com/en-us/library/bb410767(v=vs.90).aspx

Durable services require wsHttpContextBinding, which seems to be working fine. The only issues is that the WSIT client generated proxy doesn’t seem to be able to assign a instanceId to the soap envelope. Is there a config setting I am not aware of or maybe a way to intercept the outgoing messages and append the instanceId?

The following SOAP example is generated by a .NET client. The only difference between the envelop WSIT send and this one is that the Context node is missing from the WSIT one:

      <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:r="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:a="http://www.w3.org/2005/08/addressing">
        <s:Header> 
...
          <Context xmlns="http://schemas.microsoft.com/ws/2006/05/context">
            <Property name="instanceId">{I want to set this Id}</Property>
          </Context>
...
        </s:Header>
        <s:Body>
          <IncreaseCounter xmlns="http://tempuri.org/"/>
        </s:Body>
      </s:Envelope>

I hope it makes sense. The question is not ws2007HttpBinding or wsHttpBinding related or WCF instance management related like; per/call, session, single. I need help with the WSIT, Java bit only.

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

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

发布评论

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

评论(2

等待圉鍢 2024-11-01 10:07:39

我的一位从事该项目 Java 端工作的同事帮助弄清楚了语法。我分享该解决方案是因为它可能对其他人有用。这篇文章的意义在于 WSIT 文档都没有忽略提及持久 WCF 服务可以与 Java 客户端一起使用。如果您需要编写可以参与长时间运行的工作流的 java 客户端或托管 Windows 工作流 (WF) 的客户端,那么持久的 WCF 至关重要。

以下 Java 代码返回相关标头:

private static Header getContextHeader(IDemoService port) {
    Header contextHeader = null;

    Iterator<Header> iterator = ((WSBindingProvider)port).getInboundHeaders().iterator();

    while(iterator. hasNext()){        
        Header header = iterator.next();

        if (header.getLocalPart().equalsIgnoreCase("Context")) {
            contextHeader = header;
        }

    }

    return contextHeader;
}

然后您可以像这样设置 Context:

Header contextHeader = getContextHeader(port);  
((WSBindingProvider)port).setOutboundHeaders(contextHeader); 

A colleague of mine who is working on the Java end of the project helped to figure out the syntax. I share the solution because it could be useful for others. The significance of this post is that neither the WSIT documentation neglects to mention that durable WCF services can be used with Java clients. Durable WCF is essential if you need to write a java client which can participate in long running workflows or a client of a hosted Windows Workflow (WF).

The following Java code returns the relevant header:

private static Header getContextHeader(IDemoService port) {
    Header contextHeader = null;

    Iterator<Header> iterator = ((WSBindingProvider)port).getInboundHeaders().iterator();

    while(iterator. hasNext()){        
        Header header = iterator.next();

        if (header.getLocalPart().equalsIgnoreCase("Context")) {
            contextHeader = header;
        }

    }

    return contextHeader;
}

Then you can set the Context like this:

Header contextHeader = getContextHeader(port);  
((WSBindingProvider)port).setOutboundHeaders(contextHeader); 
俯瞰星空 2024-11-01 10:07:39

您可能必须指定 wcf 服务的实例管理,有 3 个选项:

  • Per call
  • Per Session
  • Single

看起来您需要每个会话。

http://www.dotnetfunda.com/articles/article912-3-ways-to-do-wcf-instance-management-per-call-per-session-and-single-.aspx

You may have to specify the instance management of the wcf service, there are 3 options:

  • Per call
  • Per Session
  • Single

Looks like you need the per session.

http://www.dotnetfunda.com/articles/article912-3-ways-to-do-wcf-instance-management-per-call-per-session-and-single-.aspx

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