I am still getting the same error.
I used the code you sent me.
function sendAndGetInfo(){
try{
var person = new Object();
person.Firstname =
document.getElementById("Firstname").value;
person.Lastname =
document.getElementById("Lastname").value;
person.Description =
document.getElementById("Description").value;
person.Latitude =
document.getElementById("Latitude").value;
person.Longatude =
document.getElementById("Longatude").value;
json_data = JSON.stringify(person);
console.log(person);
HelloWorldService.setPersonInfo(person,
handleInfoResponse);
}catch(e){
console.dir(e);
}
}
function handleInfoResponse(result) {
console.log(result);
}
this is what firebug says is being posting
{"id": 4, "method": "Service.setPersonInfo", "params": [{"Firstname":
"willis", "Lastname": "white", "Description": "sdfsdfds", "Latitude":
"23", "Longatude": "2455"}]}
this is the error I am getting
{"error":{"msg":"argument type
mismatch","trace":"java.lang.IllegalArgumentException: argument type
mismatch\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)\r\n\tat
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\r\n\tat
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)\r\n\tat
java.lang.reflect.Method.invoke(Method.java:599)\r\n\tat
org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:156)\r\n\tat
org.apache.tuscany.sca.binding.jsonrpc.provider.JSONRPCServiceServlet.handleJSONRPCMethodInvocation(JSONRPCServiceServlet.java:261)\r\n\tat
org.apache.tuscany.sca.binding.jsonrpc.provider.JSONRPCServiceServlet.handleServiceRequest(JSONRPCServiceServlet.java:164)\r\n\tat
org.apache.tuscany.sca.binding.jsonrpc.provider.JSONRPCServiceServlet.service(JSONRPCServiceServlet.java:97)\r\n\tat
javax.servlet.http.HttpServlet.service(HttpServlet.java:831)\r\n\tat
org.apache.tuscany.sca.host.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:107)\r\n\tat
org.apache.tuscany.sca.host.webapp.TuscanyServletFilter.doFilter(TuscanyServletFilter.java:94)\r\n\tat
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)\r\n\tat
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)\r\n\tat
com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)\r\n\tat
com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:852)\r\n\tat
com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:917)\r\n\tat
com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:924)
this is the beginning of the data class. I have tried this with and
without constructors and with and with out default values for the private
members.
package TOdata;
public class person {
private String FirstName = "";
private String LastName = "";
private String Longatude = "";
private String Latitude = "";
private Integer ID = 0;
private String Description = "";
public person() {
super();
}
public person(String firstName, String lastName, String longatude,
String latitude, String description) {
super();
FirstName = firstName;
LastName = lastName;
Longatude = longatude;
Latitude = latitude;
Description = description;
}
....
This is my interface class.
package helloworldjsonrpc;
import TOdata.person;
public interface HelloWorldService {
String getGreetings(String name);
person setPersonInfo(person info);
}
Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist
Code Warrior
EM:[email protected]
NM:Willis White/Poughkeepsie/IBM
From: Luciano Resende <[email protected]>
To: [email protected]
Date: 10/18/2011 01:13 AM
Subject: Re: can HelloWorldJSONRPC be modified to send objects?
On Mon, Oct 17, 2011 at 10:19 AM, Willis C White <[email protected]>
wrote:
> function sendAndGetInfo(){
> try{
> var info = new Object();
> info.Firstname =
document.getElementById("Firstname").value;
> info.Lastname =
document.getElementById("Lastname").value;
> info.Description =
document.getElementById("Description").value;
> info.Latitude =
document.getElementById("Latitude").value;
> info.Longatude =
document.getElementById("Longatude").value;
> json_data = JSON.stringify(info);
>
> console.log(json_data);
>
> HelloWorldService.setPersonInfo(json_data,
handleInfoResponse);
>
> }catch(e){
> console.dir(e);
> }
> }
You could try :
function sendAndGetInfo(){
try{
var person = new Object();
person.firstName =
document.getElementById("Firstname").value;
person.lastName =
document.getElementById("Lastname").value;
person.description =
document.getElementById("Description").value;
person.latitude =
document.getElementById("Latitude").value;
person.longitude =
document.getElementById("Longatude").value;
service.someOperation(person, handleInfoResponse);
}catch(e){
console.dir(e);
}
}
This should work, assuming your service have a "someOperation"
method that accepts a "Person" parameter that contains setters for
firstName, lastName, description, latitude and longitude.
--
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/
<<image/gif>>
<<image/gif>>
