WCF Post with Query String

…衆ロ難τιáo~ 提交于 2019-12-04 12:26:05

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.

Waking up an old thread, but thought it'd be helpful to document another way of doing it.

Changing BodyStyle of the WeInvoke method to Wrapped will solve your problem where any parameters which you don't specify on the UriTemplate are assumed to come from the request body.

The only drawback is that you'll have to wrap your post data too... and either use built-in data types as extra parameters, or define your own suitable DataContract.

Example:

[DataContract]
public class PostInfo
{
  [DataMember]
  public string Info1;
  [DataMember]
  public string Info2;
}

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

Source: msdn Forums

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!