WCF 客户端调用单向操作的问题 [英] Problem with WCF client calling one-way operation

查看:32
本文介绍了WCF 客户端调用单向操作的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从 WCF 客户端调用 SAP PI 总线上的 Web 服务时遇到问题.操作被定义为单向,我的代理操作合约上的方法在添加服务引用时进行相应的修饰.但是,服务客户端调用相应操作时出现异常:

I have run into a problem when calling web service on a SAP PI bus from my WCF client. The operation is defined as one-way, and the method on my proxy operation contract is decorated accordingly when the service reference is added. However, the service client gets an exception when calling the according operation:

单向操作返回一条非空消息,包含 Action=''

使用SoapUI,可以成功调用总线上的方法,并返回一个空体的SOAP信封.总线人员告诉我,这是根据 SOAP 规范:

Using SoapUI, the method on the bus can be called successfully, and it returns a SOAP envelope with an empty body. The bus people told me, this is according to the SOAP specs:

(SOAP 规范,第 4.7.9 章,单向操作):

(SOAP specs, chapter 4.7.9, One-way operations):

对于执行单向操作时如何使用 HTTP,有不同的解释.

There are differing interpretations of how HTTP is to be used when performing one-way operations.

R2714 对于单向操作,INSTANCE 不得返回包含信封的 HTTP 响应.具体来说,HTTP 响应 entity-body 必须为空.

R2714 For one-way operations, an INSTANCE MUST NOT return a HTTP response that contains an envelope. Specifically, the HTTP response entity-body must be empty.

R2750 在单向操作中,消费者必须忽略 HTTP 响应消息中携带的信封.

R2750 A CONSUMER MUST ignore an envelope carried in a HTTP response message in a one-way operation.

R2727 对于单向操作,消费者不得将成功的 HTTP 响应状态代码(即 2xx)解释为表示消息有效或接收方将处理它.

R2727 For one-way operations, a CONSUMER MUST NOT interpret a successful HTTP response status code (i.e., 2xx) to mean the message is valid or that the receiver would process it.

看来,我的 WCF 客户端不符合 R2750.

So it seems, my WCF client doesn't comply with R2750.

我发现当我强制代理上的操作合同为 IsOneWay = false 时,一切正常.

I have found out that when I force the operation contract on the proxy to be IsOneWay = false, everything works.

WCF 处理单向操作的方式有什么问题,还是我做错了什么(更有可能)?还有什么我应该做的吗,覆盖生成的 WCF 代理客户端似乎不正确.

Is there anything wrong with the way WCF handles one way operations or do I do something wrong (more likely)? Is there anything else I should do, it just doesn't seem right to override the generated WCF proxy client.

感谢您的任何建议.

推荐答案

看起来 SAP PI 错误地发送了一个空的 SOAP 信封,而 .NET 错误地解释了该信封.

It looks like SAP PI incorrectly sends an empty SOAP envelope and .NET incorrectly interprets that envelope.

此线程中的一些选项:

  • 更改生成的代理并将 OneWay=true(或添加 OneWay=false)删除到方法定义中
  • 在异常处理程序中捕获协议违规并忽略它
  • 使用 2.0 样式的网络引用来调用服务
  • 应用 SAP 补丁 Note 1459995 - Soap Sender Adapter HTTP 202 并将 &responsecode202=true 添加到网址
  • alter the generated proxy and remove OneWay=true (or add OneWay=false) to the method definition
  • catch the Protocol Violation in an exception handler and ignore it
  • use a 2.0 style webreference to call the service
  • apply SAP patch Note 1459995 - Soap Sender Adapter HTTP 202 and add &responsecode202=true to the url

第一个和最后一个选项都对我有用.关于此 sap.com 线程的进一步讨论.

The first and last options both worked for me. Further discussion on this sap.com thread.

这篇关于WCF 客户端调用单向操作的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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