0

I'm building WCF service where one OperationContact should consume string array on input.

The POST request is build from jQuery with $.toJSON function and looks like

    {"user":"77cae724-d5b3-412d-9499-2cfc175bf66f",
"data1":["ba3be5f2-c65d-4c21-86b1-829cad246746","604c53b1-1e24-42f7-8aba-93314eb0878e"],
"data2":"d15c3cf6-02c8-42f2-9753-ab2f5e10b21e",
"data3":["6449b58c-272c-4c98-a2fd-bd47ca248bb3","595fbefd-411e-40b1-afa1-f1f96495a8c1"]}

I create contract like:

[OperationContract]  
bool function1(string userGuid, List<string> userOrganization, List<string> userCostUnit, List<string> userGroup);

and

 [OperationContract]  
bool function1(string userGuid, string[] userOrganization, string[] userCostUnit, string[] userGroup);

But nothing seems to work. I just get 500 Internal server error. Is problem with input data (json data)?

Can you please tell me how should function deceleration looks like, to makes this work.

1
  • Check the web server logs for more info on the error causing the 500 response. Commented Oct 15, 2009 at 9:17

1 Answer 1

2

Your contract doesn't match your JSON (for example, the JSON member is called "user" but you use "userGuid" in the contract).

You can do, for example:

[WebInvoke(RequestFormat = WebMessageFormat.Json)] [OperationContract] bool function1(Guid user, List data1, Guid data2, List data3);

You may also need to play with WebInvoke.BodyStyle to make this work - I think it should be "Wrapped".

Sign up to request clarification or add additional context in comments.

1 Comment

I implement serializeObject function from this answer stackoverflow.com/questions/1184624/… but in fact it doesn't work with multiple select items :(

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.