We have a WCF Rest Json service hosted on the server and it consume from the native iPad application. Most of the users , it works fine while calling WCF service. But for some users, we found that WCF receives the currupted or clipped Json string. Some part of the Json string is clipped and it failed to deserialize from the service end.
For the account creation issue , we have added the logging of the service exception in the webservice to the notepad file. We got the exceptions from the notepad file. Right now we could see the parameters to the services is missing for those users.and it cause the error while deserializing the parameter. We need to check the app side why the the parameters are coming as empty. Right now we got the same user account creation exceptionentries from the "50.143.85.75" IP.
We have WCF Rest service CreateUser"as like below. We are consuming this service from the IOS app.
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Json,
UriTemplate = "CreateUser/")]
[OperationContract]
CustomServiceResponse CreateUser(Stream userdetails);
Method Implementation code is like below.
public CustomServiceResponse CreateUser(Stream user)
{
var stream = new StreamReader(user);
string streamcontent = stream.ReadToEnd();
UserInformation userInformation = ConvertJSonToObject<UserInformation>(streamcontent);
}
Following are the biding configuration
<binding name="webHttpBindingStreamed"
transferMode="Streamed"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
openTimeout="00:25:00"
closeTimeout="00:25:00"
sendTimeout="00:25:00"
receiveTimeout="00:25:00"></binding>
</webHttpBinding>
Right now the service converting the stream to string and doing all operations. But for sometime we are getting error. We have logged the streamcontent when the deserialization failure. we could see that serialization failing when the streamcontent is not containg full json string. below you can see the json string we got while we got the exception. you can see the double quotes and closing bracket missing from the first json string and some letter ("false") and closing bracket skipped from second json String.
{"FirstName":"Donald","LastCBPaymentType":6,"AcceptEmail":true,"CellPhone":"111-111-6874","Position":"3","UserAccountDateTime":"\/Date(1457055496621+0800)\/","CBExpirationDate":"\/Date(1465862400000+0800)\/","Email":"test.test@gmail.com","Password":"test","IsNeedtoGiveFreeOneMonth":false,"LastName":"test","WBExpirationDate":null,"IpAddress":"72.188.215.34","CarrierNum":"4","EmpNum":"96874
{"Position":"4","Email":"Tim.rrrr@wnco.com","CellPhone":"111-11-6146","LastCBPaymentType":6,"EmpNum":"107333","FirstName":"Timothy","Password":"eeee","WBExpirationDate":null,"UserAccountDateTime":"\/Date(1457054214674+0800)\/","CarrierNum":"5","CBExpirationDate":"\/Date(1468281600000+0800)\/","AcceptEmail":true,"IpAddress":"73.209.67.242","LastName":"Hill","IsNeedtoGiveFreeOneMonth":fa
Do you know why this some portion of the json string clipped ? Is there any serialization issue from the IOS side?