How can I call a WCF method with the type POST from a C# class?
WCF method
[OperationContract]
[WebInvoke(Method = "POST",
UriTemplate = "/process",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped)]
MyRespons Process(MyRequest req);
How can I call this from an aspx codebehind?
I’ve tried to receive the stream with webclient, it works with any get method, but not with POST. The method works in Fiddler and POSTER:
string getDeclarations = string.Format("{0}/process", ServiceBaseAddress);
var proxy = new WebClient();
proxy.DownloadStringCompleted += ProxyDownloadDeclarationsCompleted;
proxy.DownloadStringAsync((new Uri(getDeclarations)));
You can do this using jQuery. And here is a great example for you to use as well.
This is an example code block.
Edited
Here is a reference to a Stackoverflow example using
WebClientto perform aPOST.