views:

111

answers:

1

Hi All,

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 this. _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

+1  A: 

What about:

[OperationContract,
 WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json)]
Rubens Farias
Sweet. Thanks for the help!
Hcabnettek