开发者

ASP.NET Ajax-enabled WCF Service, how can I 'post' instead of 'get'?

I'm using a simple ajax-enabled WCF service. I'm creating a string of XML on the client and doing a get (by default). Here is the code. I see the 'WebGet' attribute, but there's no 'WebPost'

  [OperationContract, WebGet(ResponseFormat = WebMessageFormat.Json)]
    public string PrepareDoc(string inputXML)
    {
        var arg = new CommandArg();
        arg.ParamCollection.Add("inputXML", inputXML);
        var result = LetterBLL.DoLetter(new PrepareDocCmd(), arg);


        return result.ScalarResult.ToString();
    }

This returns a serialized string I can eval on the client. This all works good. I do have a problem when inputXML exceeds the IE Url max length of 2048. I get a javascript error saying resource not available. The solution besides making the URL smaller is to switch to a POST. How can I do this? Also should I be sending json to the service instead of a string of XML

On the client I register the service reference inside a script manager so it creates the proxy ojects. I call the service from javascript like th开发者_运维技巧is. _prepareDoc references the service method inside a client object.

 this._prepareDoc(sb.toString(), successFunc, failFunc, this);

How do I change this to do a post? Also on the server what do I need to change? I am currently taking in a string of XML as the input.

Thanks so much for any tips, ~ck in San Diego


What about:

[OperationContract,
 WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json)]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜