Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    #16
    The signature of execute has changed to

    public void execute(Object[] data)

    Sanjiv

    Comment


      #17
      Thank you Sanjiv - I am not only newbe but also stupid.
      But I did it now like in the updated showcase WSDL example:
      Code:
                       service.callOperation("hello", data, "helloResponse", new WebServiceCallback() {
                           @Override
                           public void execute(Object[] data) {
                               System.out.println("!");
                               Form.this.setValue("Answer", (String)data[0]);
                           }
                       });
      and got cast exception:
      Code:
      Uncaught JavaScript exception [java.lang.ClassCastException: com.google.gwt.core.client.JavaScriptObject$ cannot be cast to java.lang.String
              at org.yournamehere.client.MainEntryPoint$Form$1.execute(MainEntryPoint.java:101)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
              at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
              at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
              at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
              at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
              at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
              at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
              at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
              at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
              at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
              at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
              at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)] in http://localhost:8080/HelloGWT/hosted.html?org_yournamehere_Main, line 6
      MichalG

      Comment


        #18
        data[0] might be a returned as a complex type and hence of type JavaScript object. Can you place a breakpoint the callback and let us know what data[0] evaluates to?

        Code:
        public void execute(Object[] data) {
            Object dataVal = data[0];
            System.out.println("!");
            
            //Form.this.setValue("Answer", (String)data[0]);
        }

        Comment


          #19
          data[0] evaluates to object of class com.google.gwt.core.client.JavaScriptObject$
          MichalG

          Comment


            #20
            Can you report two more things :

            data[0].toString() and

            JSOHelper.getPropertiesAsString(data[0])

            Thanks,
            Sanjiv

            Comment


              #21
              Code:
                                       System.out.println(data[0].toString());
                                       System.out.println(JSOHelper.getPropertiesAsString((JavaScriptObject) data[0]));
              Code:
              [object Object]
              {
              xmlns:ns
              return}
              MichalG

              Comment


                #22
                Hi MichalG,

                So this means you're all set, right? Those objects are what the docs tell you to expect (the results of toJS()), and presumably you see how to use JSOHelper to extract whatever you want for them?

                Comment


                  #23
                  Well, sorry for my ignorance but I am expecting return string like "Hello xxx" from webservice and can't extract it from JS object.
                  The service itself is working fine both when issued from browser and from console WSDL tab.
                  Thanks,
                  MichalG

                  Comment


                    #24
                    If you add the line SC.debugger() in the execute callback, and run in FF with Firebug a breakpoint will be hit at this line and you can examine and evaluate the structure of data and how to extract your return String. If you're running in IE and have the IE JS debugger, it will be triggered as well.

                    Sanjiv

                    Comment


                      #25
                      Thank you Isomorphic and Sanjiv.

                      In the meantime I finally managed to create and then use in SmartGWT Axis2 based services: Restful and SmartClientOperations WSDL.

                      Assuming that I am going to create new services from scratch (only the existing database structure would be used in the new project), what is a better approach from a piont of view SmartGWT frontend:
                      WSDL or Restful ?
                      MichalG

                      Comment


                        #26
                        My suggestion would be to use Restful services if you're only talking to your backend. They are lightweight, easy to use and it very simple to have the webserver spit out the appropriate JSON / XML in response to a Restful request. There are several ways to do this and my preferred stack would be to use Spring MVC to accept the restful request, read the request params, invoke a service API call to retrieve the model beans and finally convert to XML / Json using XStream.

                        Sanjiv

                        Comment

                        Working...
                        X