Hi,
I am calling AJAX enabled WCF Service from android using HttpPost. I am passing JSONObject as data. The JSONObject is in the following format,
{"Enq":
{
"Enquiry":
{
"EnquiryDate":"2013-9-30",
"Remarks":"Mke it soon.",
"Location":"Chennai",
"Id":1,
"RequiredDate":"2013-10-30"
},
"EnquiryDetails":
[
{"SaleCondition":"IIWL","EnquiryId":1,"Type":"GP","NoOfUnits":54,"Size":"4"}{"SaleCondition":"ASIS","EnquiryId":1,"Type":"GP","NoOfUnits":23,"Size":"40"}, {"SaleCondition":"IIWL","EnquiryId":1,"Type":"GP","NoOfUnits":34,"Size":"40"}
]
}
}
I use the following code to call the Wcf Service,
DefaultHttpClient httpClient = new DefaultHttpClient();
URI uri = null;
uri = new URI("http://10.1.193.172/iTradeIntegration/MobileApp.svc");
HttpPost httppost=new HttpPost(uri +"/enquirySync");
StringEntity se = new StringEntity( parent.toString());
//parent is JSONObject which is in the above format
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httppost.setEntity(se);
httppost.setHeader("Accept", "application/json");
httppost.setHeader("Content-type", "application/json; charset=utf-8");
HttpResponse response = null;
response = httpClient.execute(httppost);
And in the WCF Service, i defined the function to consume the HttpPost as follow,
<operationcontract()> _
<webinvoke(method:> _
Public Function enquirySync(Enq As List(Of JsonObject)) As String
Return "Hi"
End Function
End Class
I defined the classes to consume the values. Those are given below.
Public Class Enquiry
Public Property EnquiryDate() As String
Get
Return m_EnquiryDate
End Get
Set(value As String)
m_EnquiryDate = Value
End Set
End Property
Private m_EnquiryDate As String
Public Property Remarks() As String
Get
Return m_Remarks
End Get
Set(value As String)
m_Remarks = Value
End Set
End Property
Private m_Remarks As String
Public Property Location() As String
Get
Return m_Location
End Get
Set(value As String)
m_Location = Value
End Set
End Property
Private m_Location As String
Public Property Id() As Integer
Get
Return m_Id
End Get
Set(value As Integer)
m_Id = Value
End Set
End Property
Private m_Id As Integer
Public Property RequiredDate() As String
Get
Return m_RequiredDate
End Get
Set(value As String)
m_RequiredDate = Value
End Set
End Property
Private m_RequiredDate As String
End Class
Public Class EnquiryDetail
Public Property SaleCondition() As String
Get
Return m_SaleCondition
End Get
Set(value As String)
m_SaleCondition = Value
End Set
End Property
Private m_SaleCondition As String
Public Property EnquiryId() As Integer
Get
Return m_EnquiryId
End Get
Set(value As Integer)
m_EnquiryId = Value
End Set
End Property
Private m_EnquiryId As Integer
Public Property Type() As String
Get
Return m_Type
End Get
Set(value As String)
m_Type = Value
End Set
End Property
Private m_Type As String
Public Property NoOfUnits() As Integer
Get
Return m_NoOfUnits
End Get
Set(value As Integer)
m_NoOfUnits = Value
End Set
End Property
Private m_NoOfUnits As Integer
Public Property Size() As String
Get
Return m_Size
End Get
Set(value As String)
m_Size = Value
End Set
End Property
Private m_Size As String
End Class
Public Class Enq
Public Property Enquiry() As Enquiry
Get
Return m_Enquiry
End Get
Set(value As Enquiry)
m_Enquiry = Value
End Set
End Property
Private m_Enquiry As Enquiry
Public Property EnquiryDetails() As List(Of EnquiryDetail)
Get
Return m_EnquiryDetails
End Get
Set(value As List(Of EnquiryDetail))
m_EnquiryDetails = Value
End Set
End Property
Private m_EnquiryDetails As List(Of EnquiryDetail)
End Class
Public Class JsonObject
Public Property Enq() As Enq
Get
Return m_Enq
End Get
Set(value As Enq)
m_Enq = Value
End Set
End Property
Private m_Enq As Enq
End Class
I am not getting the values which i have passed from android. Please help me to solve this. I am getting "nothing" for the values.