WCF邮政与查询字符串 [英] WCF Post with Query String

查看:188
本文介绍了WCF邮政与查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个Windows服务托管WCF服务。该方法的一个具有被设置为从一个支付提供者接收的回调的URI。这是接口的合同...

I am currently developing a Windows Service hosted WCF service. One of the methods has a URI which is set up to receive a callback from a payment provider. This is the interface contract...

    [OperationContract]
    [WebInvoke(UriTemplate = "3DSecureCallback?TrxId={id}", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)]
    void ThreeDSecureCallBack(string id, Stream body);

这个问题我遇到的是第三方提供的职位,以我们的服务。我必须提供一个回调URL给它。因此,我们可以调和付款,我们提供包含事务ID查询字符串参数的URL。

This issue I am having is that the 3rd party provider posts to our service. I have to provide a callback url to it. So we can reconcile payments, we provide a URL with a query string parameter containing the transaction id.

在此服务的发展,回调是成功的。 (这是之前添加蒸汽参数)

During development of this service, the call backs have been successful. (This was prior to adding the Steam parameter)

不过,我们现在正处于我们需要分析的数据发布阶段。这是第2次流参数加入到该方法签名点

However, we are now at the stage where we need to parse the posted data. This is the point that the 2nd 'Stream' parameter was added to the method signature.

这是我收到的问题是,我收到以下异常...

The issue that I am getting is that I receive the following exception...

For request in operation ThreeDSecureCallBack to be a stream the operation must have a single parameter whose type is Stream.

通过删除ID参数,并且只具有流,我们就可以得到这个职位的数据。这在实践中行不通,虽然我需要查询字符串放慢参数也。

By removing the id parameter, and having stream only, we can get the post data. This won't work in practice though as I need to query string paramter also.

任何人都可以就如何解决这个问题吗?我真的很茫然。

Can anyone advise on how to resolve this issue please? I am really at a loss.

在此先感谢,

大卫

推荐答案

您可以访问查询字符串ID值,如下所示

You can access the querystring "id" value as shown below

WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters [ID]

现在你只能有一个参数的类型的流的方法。

Now you can have only one parameter to your method of type stream.

这篇关于WCF邮政与查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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