Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET WCF JSON Post
Can anyone please help me determine why my wrapped JSON parameters are coming in NULL?
 
I'm trying to integrate a vendor's product into our internal software and have created a WCF web service to handle their POST requests.
 
The vendor's JSON data format in the request body look like this:
{ "Call": { "call_detail_id": "3514736", "ouid": "7425" } }
 
If I create a test interface with WebMessageBodyStyle.Bare and pass in a couple JSON parameters, it works great. However, the vendor's typed JSON is not coming through.
 
Any help would be very much appreciated.
 
Thanks,
 

Andre Ranieri
 

[ServiceContract]
    public interface IMyService    
{
        [OperationContract]
        [WebInvoke(
               Method = "POST", 
               UriTemplate = "post-call/",
               RequestFormat = WebMessageFormat.Json, 
               ResponseFormat = WebMessageFormat.Json,
               BodyStyle = WebMessageBodyStyle.WrappedRequest
               )
        ]
        string lmc_BusinessLogic(Call myCall);
 
    }
 

    public class Call
    {
        [DataMember(Name = "call_detail_id")]
        public string call_detail_id { get; set; }
        [DataMember(Name = "ouid")]
        public string ouid { get; set; }
 
    }
 

Implementation:
 
public string lmc_BusinessLogic(Call myCall)
        {
            // myCall object is null when passed in here.
            // Implement some business logic once the parms are getting passed.

        }
Posted 7-May-13 14:01pm
Edited 7-May-13 19:46pm
vijay__p4.7K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Change
BodyStyle = WebMessageBodyStyle.WrappedRequest to BodyStyle = WebMessageBodyStyle.Bare
also change
{ "Call": { "call_detail_id": "3514736", "ouid": "7425" } } to { "myCall": { "call_detail_id": "3514736", "ouid": "7425" } }
Hope this helps
  Permalink  
v2

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

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 BillWoodruff 85
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 8 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100