I have a WCF service with a custom class object as paramter.
MyClass Call(MyParameter Parameter)
I need to pass this object, Parameter, to this service and proceed with the rest of the operations in the service. I need to call this service through JQuery. I tried JSON object but it does not work, I must be doing something wrong if it should work, that is.
$.ajax({
type: "GET",
url: "http://localhost:56779/Service.svc/web/Call",
data: { Parameter: parameter },
contentType: "application/json; charset=utf-8",
dataType: "json",
username: "xxxx",
password: "yyyy",
processData: true,
success: function (msg) {
console.log(msg);
},
error: function (e) {
alert('Error!');
}
});
with
var parameter = {
"Parameter": {
"ID": "A5",
"Var": "5",
"Reference": {
"ID": "12345678"
},
"Order": {
"ID": 10,
"Category": {
"Price": {
"Value": "1000"
},
"Quantity": {
"Value": 4
},
"Date": "1/14/2013"
}
}
}
};
I also tried
data: JSON.stringify(parameter)
but it doesn't work, service is not even called and error occurs. Please let me know how to go about it.
My real task is to send such object as a SOAP message and get a SOAP response; if I don't need to go through JSON, then please guide me directly to achieve my goal.
P.S. I would want to know how to send objects to WCF service, with or without SOAP so, when I'm guided to my goal, I'd be glad to have another guidance regarding this extra goal.
Thanks!