简体   繁体   中英

WCF Ajax service - How can I pass an Array or JSON to the service? What should the method parameter type be?

I have a very simple WCF service I would like to pass it an array or json?

[OperationContract, WebGet(ResponseFormat = WebMessageFormat.Json)]
    public string GetPreDisplay(string inputData)
    {
        //DoSomething with inputData
        return "Sweet!";
    }

My javascript...

 var data = [paymentControls['claimNum'], paymentControls['claimSeq']];
        $lps.GetPreDisplay(data, onComplete);

Obviously string is the wrong type. Can anyone point me in the right direction?

Thanks, ~ck

With ASP.Net MVC you can return data as an ActionResult, there is a method "Json" which converts the data to the correct format. Have a look at this other question:

wcf json web service

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM