Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
can we post json array data to wcf but before posting we need to check whether some condition are true or false.
I mean i will have to check whether a particular value ie:Transaction ID is available in my table if it is tru the i will post json.

I know that we need two urls to be passed: one for checking value in table and another for posting json.

But is that possible that we can do the both using same url.

Thanks in advance,
-navdeepsingh
Posted

1 solution

No, this can be done using one URL only.
You can check condition using the same URL that you want to post your data. Pass the condition as a parameter to the WCF method along with the data you want to post.

First check your condition using the first parameter and if its true save the data.

Simple ? ;)

-KR
 
Share this answer
 
Comments
[no name] 17-Sep-15 2:52am    
Hi KR,

Thamks for quick reply

I am using this in my IPostCancelStatus.cs file of wcf service
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
void SetCancelStatus(List<cancelstatus> cancelstatus, string txtDR_IMEI, string txtAR_ApplicationName, string lngAR_VerifyCode);

actually i am posting json from android which works without those string parameters but not otherway round
i had checked on fidler
Krunal Rohit 17-Sep-15 3:00am    
Just want to know where does this TransactionID come in picture ?

-KR
[no name] 17-Sep-15 3:08am    
Scenerio:

We have got an android app
We need to post json data to wcf service where the data is inserted Table1 in db
Before inserting we need to check whether IMEINO,ApplicationName,VerifyCode passed as parameters match with that in from Table2 in db

"Sorry for that Transaction no thing wronly posted"
Do you need any other info.
:)
Krunal Rohit 17-Sep-15 3:11am    
Then you have to get the from the Table2 and check with the data that is posted from the app, and if it matches with your criteria, you're good to go.
You can CHECK and INSERT in single call only, for that you need to code that way.

Cheers! :)

-KR
[no name] 17-Sep-15 3:27am    
Yes You are right it worked!
Thank You :)
Navdeep Singh.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900