You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Willis C White <wh...@us.ibm.com> on 2011/10/17 16:21:58 UTC

can HelloWorldJSONRPC be modified to send objects?

I am trying to send a collection of data (Stings and Doubles) to the back 
end (without Dojo). I see there is a scaDomain.js file that seems to be 
doing the work - but I can't find it.

1. Is there an example of sending an object to the back end using WAS - 
that I could look at?

2. Where is scaDomain.js located? 

2a. Can I still use scaDomain.js if I want to send an object and not just 
a primitive?


Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist 
Code Warrior 





Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Willis C White <wh...@us.ibm.com>.
Instead of debugging my personal  project could someone just state or post 
the changes that need to be made to the HelloWorldJSONRPC sample so that 
an object can be sent to the back end instead of a primative?


Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist 
Code Warrior 
Home office 845-331-5134, Cell 845-853-3827 
"This quote was intentionally left blank " 

EM:whiwill@us.ibm.com
NM:Willis White/Poughkeepsie/IBM





From:   Willis C White/Poughkeepsie/IBM@IBMUS
To:     user@tuscany.apache.org
Date:   10/18/2011 03:21 PM
Subject:        Re: can HelloWorldJSONRPC be modified to send objects?



I still have the problem. Fix one thing 

these two line where wrong 

info.Firstname = document.getElementById("Firstname").value;
info.Lastname = document.getElementById("Lastname").value; 

should be FirstName and LastName (not Firstname and Lastname) 

are the constructors I have in my earlier post, wrong?

Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist 
Code Warrior 
Home office 845-331-5134, Cell 845-853-3827 
"This quote was intentionally left blank " 

EM:whiwill@us.ibm.com
NM:Willis White/Poughkeepsie/IBM 






From:        Luciano Resende <lu...@gmail.com> 
To:        user@tuscany.apache.org 
Date:        10/18/2011 01:34 PM 
Subject:        Re: can HelloWorldJSONRPC be modified to send objects? 



On Tue, Oct 18, 2011 at 5:50 AM, Willis C White <wh...@us.ibm.com> 
wrote:
>
> 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:whiwill@us.ibm.com
> NM:Willis White/Poughkeepsie/IBM
>
>
>
>
> From:        Luciano Resende <lu...@gmail.com>
> To:        user@tuscany.apache.org
> 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 <wh...@us.ibm.com> 
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.
>
>
> --

Two things :

a) Case of the properties person.firstName versus person.Firstname, it
should be firstName

b) Your Person class should be a valid bean : default constructors,
getters/setters for every property


--
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/



Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Luciano Resende <lu...@gmail.com>.
On Thu, Oct 20, 2011 at 5:43 AM, Willis C White <wh...@us.ibm.com> wrote:
>
> thank you for providing the demo.
>
> sorry to keep asking for more but my knowledge of how this all works is seriously lacking.  In the HelloWorldJSONRPC example tuscany is started from the web.xml using a filter - does this serve the same purpose as the Launch.java class you have?
>

Yes

> You also have some dojo included in you example but I don't see where it is used. Did I miss something? If so what?
>

Some of the dojo details are hidden in the widget (see generated
widget.js), but when i do
personService.createPerson(person).addCallback... that's basically
invoking a remote service via json-rpc using dojo.

> The sample in the distribution is very close to what I need - starting Tuscany form web.xml and not using dojo. I just need it to send objects to back end.

Good luck, you should be able to identify the things your application
needs from the sample I provided. Please see how the model pojo is
defined, the interface and annotations on the interface, and you
should be good to go.

--
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Willis C White <wh...@us.ibm.com>.
thank you for providing the demo. 

sorry to keep asking for more but my knowledge of how this all works is 
seriously lacking.  In the HelloWorldJSONRPC example tuscany is started 
from the web.xml using a filter - does this serve the same purpose as the 
Launch.java class you have?

You also have some dojo included in you example but I don't see where it 
is used. Did I miss something? If so what?

The sample in the distribution is very close to what I need - starting 
Tuscany form web.xml and not using dojo. I just need it to send objects to 
back end.


Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist 
Code Warrior 

EM:whiwill@us.ibm.com
NM:Willis White/Poughkeepsie/IBM





From:   Luciano Resende <lu...@gmail.com>
To:     user@tuscany.apache.org
Date:   10/19/2011 04:36 PM
Subject:        Re: can HelloWorldJSONRPC be modified to send objects?





Ok, I guess it's really easy with access to the code, please find a 
working example at 
https://svn.apache.org/repos/asf/tuscany/sandbox/lresende/sca-2.x/samples/person-jsonrpc/


-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Luciano Resende <lu...@gmail.com>.
On Wed, Oct 19, 2011 at 5:45 AM, Willis C White <wh...@us.ibm.com> wrote:

> implements java.io.Serializable {
>
>     private String FirstName;
>     private String LastName;
>     private String Longatude;
>     private String Latitude;
>     private Integer ID;
>     private String Description;
>
>
>     public person() {
>     }
>
>     public void setFirstName(String firstName) {
>         this.FirstName = firstName;
>     }
>
>     public String getFirstName() {
>         return this.FirstName;
>     }
>
>     public String getLastName() {
>         return this.LastName;
>     }
>     public void setLastName(String lastName) {
>         this.LastName = lastName;
>     }
>     public String getLongatude() {
>         return this.Longatude;
>     }
>     public void setLongatude(String longatude) {
>         this.Longatude = longatude;
>     }
>     public String getLatitude() {
>         return this.Latitude;
>     }
>     public void setLatitude(String latitude) {
>         this.Latitude = latitude;
>     }
>     public Integer getID() {
>         return this.ID;
>     }
>     public void setID(Integer id) {
>         this.ID = id;
>     }
>     public String getDescription() {
>         return this.Description;
>     }
>     public void setDescription(String description) {
>         this.Description = description;
>     }
>
> }


Ok, I guess it's really easy with access to the code, please find a working
example at
https://svn.apache.org/repos/asf/tuscany/sandbox/lresende/sca-2.x/samples/person-jsonrpc/

-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Willis C White <wh...@us.ibm.com>.
Still get the error below is my data class and the output from fireBug

package TOdata;

public class person implements java.io.Serializable {

    private String FirstName;
    private String LastName;
    private String Longatude;
    private String Latitude;
    private Integer ID;
    private String Description;
    
    
    public person() {
    }

    public void setFirstName(String firstName) {
        this.FirstName = firstName;
    }
    
    public String getFirstName() {
        return this.FirstName;
    }
    
    public String getLastName() {
        return this.LastName;
    }
    public void setLastName(String lastName) {
        this.LastName = lastName;
    }
    public String getLongatude() {
        return this.Longatude;
    }
    public void setLongatude(String longatude) {
        this.Longatude = longatude;
    }
    public String getLatitude() {
        return this.Latitude;
    }
    public void setLatitude(String latitude) {
        this.Latitude = latitude;
    }
    public Integer getID() {
        return this.ID;
    }
    public void setID(Integer id) {
        this.ID = id;
    }
    public String getDescription() {
        return this.Description;
    }
    public void setDescription(String description) {
        this.Description = description;
    }
    
}




JSON






id
2

method
"Service.setPersonInfo"

params
[Object { FirstName="joey", LastName="Johnson", Description="all the 
desc", more...}]

0
Object { FirstName="joey", LastName="Johnson", Description="all the desc", 
more...}

Description
"all the desc"

FirstName
"joey"

ID
0

LastName
"Johnson"

Latitude
"234"

Longatude
"567"


Source
{"id": 2, "method": "Service.setPersonInfo", "params": [{"FirstName": 
"joey", "LastName": "Johnson", "Description": "all the desc", "Latitude": 
"234", "Longatude": "567", "ID": 0}]}




Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist 
Code Warrior 
Home office 845-331-5134, Cell 845-853-3827 
"This quote was intentionally left blank " 

EM:whiwill@us.ibm.com
NM:Willis White/Poughkeepsie/IBM





From:   Luciano Resende <lu...@gmail.com>
To:     user@tuscany.apache.org
Date:   10/18/2011 06:50 PM
Subject:        Re: can HelloWorldJSONRPC be modified to send objects?



On Tue, Oct 18, 2011 at 12:09 PM, Willis C White <wh...@us.ibm.com> 
wrote:
>
> I still have the problem. Fix one thing
>
> these two line where wrong
>
> info.Firstname = document.getElementById("Firstname").value;
> info.Lastname = document.getElementById("Lastname").value;
>
> should be FirstName and LastName (not Firstname and Lastname)
>
> are the constructors I have in my earlier post, wrong?

Yes, see [1]... default no arg constructor and getters and setters for
all the properties

[1] http://en.wikipedia.org/wiki/JavaBean

--
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/



Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Luciano Resende <lu...@gmail.com>.
On Tue, Oct 18, 2011 at 12:09 PM, Willis C White <wh...@us.ibm.com> wrote:
>
> I still have the problem. Fix one thing
>
> these two line where wrong
>
> info.Firstname = document.getElementById("Firstname").value;
> info.Lastname = document.getElementById("Lastname").value;
>
> should be FirstName and LastName (not Firstname and Lastname)
>
> are the constructors I have in my earlier post, wrong?

Yes, see [1]... default no arg constructor and getters and setters for
all the properties

[1] http://en.wikipedia.org/wiki/JavaBean

--
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Willis C White <wh...@us.ibm.com>.
I still have the problem. Fix one thing

these two line where wrong

info.Firstname = document.getElementById("Firstname").value;
info.Lastname = document.getElementById("Lastname").value;

should be FirstName and LastName (not Firstname and Lastname)

are the constructors I have in my earlier post, wrong?


Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist 
Code Warrior 
Home office 845-331-5134, Cell 845-853-3827 
"This quote was intentionally left blank " 

EM:whiwill@us.ibm.com
NM:Willis White/Poughkeepsie/IBM





From:   Luciano Resende <lu...@gmail.com>
To:     user@tuscany.apache.org
Date:   10/18/2011 01:34 PM
Subject:        Re: can HelloWorldJSONRPC be modified to send objects?



On Tue, Oct 18, 2011 at 5:50 AM, Willis C White <wh...@us.ibm.com> 
wrote:
>
> 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:whiwill@us.ibm.com
> NM:Willis White/Poughkeepsie/IBM
>
>
>
>
> From:        Luciano Resende <lu...@gmail.com>
> To:        user@tuscany.apache.org
> 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 <wh...@us.ibm.com> 
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.
>
>
> --

Two things :

a) Case of the properties person.firstName versus person.Firstname, it
should be firstName

b) Your Person class should be a valid bean : default constructors,
getters/setters for every property


--
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/



Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Luciano Resende <lu...@gmail.com>.
On Tue, Oct 18, 2011 at 5:50 AM, Willis C White <wh...@us.ibm.com> wrote:
>
> 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:whiwill@us.ibm.com
> NM:Willis White/Poughkeepsie/IBM
>
>
>
>
> From:        Luciano Resende <lu...@gmail.com>
> To:        user@tuscany.apache.org
> 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 <wh...@us.ibm.com> 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.
>
>
> --

Two things :

a) Case of the properties person.firstName versus person.Firstname, it
should be firstName

b) Your Person class should be a valid bean : default constructors,
getters/setters for every property


--
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/

Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Willis C White <wh...@us.ibm.com>.
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:whiwill@us.ibm.com
NM:Willis White/Poughkeepsie/IBM





From:   Luciano Resende <lu...@gmail.com>
To:     user@tuscany.apache.org
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 <wh...@us.ibm.com> 
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/



Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Luciano Resende <lu...@gmail.com>.
On Mon, Oct 17, 2011 at 10:19 AM, Willis C White <wh...@us.ibm.com> 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/

Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Willis C White <wh...@us.ibm.com>.
Here is the code I am trying to execute. Right now I am just passing a 
string the represents the json and I am parsing it on the back-end. This 
way of doing is seems to defeat some of the purpose of using Tuscany. So I 
am wondering if there is a better way.

  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);
           }      
       }
       
       function handleInfoResponse(result) {
           console.log(result);
       } 


Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist 
Code Warrior  







From:   Willis C White/Poughkeepsie/IBM@IBMUS
To:     user@tuscany.apache.org
Date:   10/17/2011 12:24 PM
Subject:        Re: can HelloWorldJSONRPC be modified to send objects?



I am using Tuscany 1.6 with WAS 7.0 in RAD 7.5

Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist 
Code Warrior 

EM:whiwill@us.ibm.com
NM:Willis White/Poughkeepsie/IBM 






From:        Simon Laws <si...@googlemail.com> 
To:        user@tuscany.apache.org 
Date:        10/17/2011 11:59 AM 
Subject:        Re: can HelloWorldJSONRPC be modified to send objects? 





On Mon, Oct 17, 2011 at 3:21 PM, Willis C White <wh...@us.ibm.com> 
wrote: 
I am trying to send a collection of data (Stings and Doubles) to the back 
end (without Dojo). I see there is a scaDomain.js file that seems to be 
doing the work - but I can't find it. 

1. Is there an example of sending an object to the back end using WAS - 
that I could look at? 

2. Where is scaDomain.js located? 

2a. Can I still use scaDomain.js if I want to send an object and not just 
a primitive? 

Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist 
Code Warrior 





Hi Willis

What version of Tuscany are you on? 

Regards

Simon


-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com 

Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Willis C White <wh...@us.ibm.com>.
I am using Tuscany 1.6 with WAS 7.0 in RAD 7.5


Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist 
Code Warrior 

EM:whiwill@us.ibm.com
NM:Willis White/Poughkeepsie/IBM





From:   Simon Laws <si...@googlemail.com>
To:     user@tuscany.apache.org
Date:   10/17/2011 11:59 AM
Subject:        Re: can HelloWorldJSONRPC be modified to send objects?





On Mon, Oct 17, 2011 at 3:21 PM, Willis C White <wh...@us.ibm.com> 
wrote:
I am trying to send a collection of data (Stings and Doubles) to the back 
end (without Dojo). I see there is a scaDomain.js file that seems to be 
doing the work - but I can't find it. 

1. Is there an example of sending an object to the back end using WAS - 
that I could look at? 

2. Where is scaDomain.js located? 

2a. Can I still use scaDomain.js if I want to send an object and not just 
a primitive?

Willis C. White III
Software Engineer, CIO Lab
IBM Certified IT Specialist 
Code Warrior 




Hi Willis

What version of Tuscany are you on? 

Regards

Simon


-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com

Re: can HelloWorldJSONRPC be modified to send objects?

Posted by Simon Laws <si...@googlemail.com>.
On Mon, Oct 17, 2011 at 3:21 PM, Willis C White <wh...@us.ibm.com> wrote:

> I am trying to send a collection of data (Stings and Doubles) to the back
> end (without Dojo). I see there is a scaDomain.js file that seems to be
> doing the work - but I can't find it.
>
> 1. Is there an example of sending an object to the back end using WAS -
> that I could look at?
>
> 2. Where is scaDomain.js located?
>
> 2a. Can I still use scaDomain.js if I want to send an object and not just a
> primitive?
>   [image: Innovation Initiatives Graphic]<http://w3.ibm.com/connections/communities/service/html/communityview?communityUuid=f386626f-9412-4df4-8515-cce6c3c3ea4a>
> *Willis C. White III**
> Software Engineer, CIO Lab*
> IBM Certified IT Specialist
> Code Warrior
>  *
> *
> [image: IBM Logo] <http://www.ibm.com>
>
>
Hi Willis

What version of Tuscany are you on?

Regards

Simon


-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com