Announcement

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

    Web Service and ListGrid

    Does anyone know of any examples online of binding a web service as a DataSource to a ListGrid with SmartGWT? There are a few examples of binding a web service as a DataSource to a DynamicForm, but we're looking to bind it to a ListGrid, and having trouble.

    #2
    Like this?

    Comment


      #3
      Originally posted by Isomorphic
      Like this?
      Unfortunately that's with SmartGWT EE. Are there any examples with just SmartGWT? Can it be done without EE?

      Comment


        #4
        Yes, same code, but with the lack of a proxy you will need to make the WSDL file and the service itself available on the same machine that serves the primary web page.

        Make sure all URLs you use are relative, that is, no "http://" even if the hostname is localhost. Also, using a different port is also considered a different host by some browsers, so avoid that.

        Or just use Pro/EE.

        Comment


          #5
          Originally posted by Isomorphic
          Yes, same code, but with the lack of a proxy you will need to make the WSDL file and the service itself available on the same machine that serves the primary web page.

          Make sure all URLs you use are relative, that is, no "http://" even if the hostname is localhost. Also, using a different port is also considered a different host by some browsers, so avoid that.

          Or just use Pro/EE.
          Thanks for the response. When you say to use relative URLs, do you mean in the .wsdl file itself?

          Regarding the example in the SmartGWT EE Showcase, is the .wsdl file available anywhere?

          Comment


            #6
            No, it means in calls to loadWSDL() and in the WSDL file itself (for the service location), or, manually call setLocation() on the WebService instance to correct the URL if you can't make it relative in the WSDL.

            You can see the URL of the WSDL file in that sample and/or use the Net panel in Firebug to capture it.

            Comment


              #7
              I tried this example and it works fine (PRO Version)
              However my Web Service is on Port 8082 and when I try to use it I get the Error

              Transport error - HTTP code: 500 for URL: http://srvr:8082/MyService/ServicePort?wsdl (via proxy: http://localhost:8888/testproject/sc/HttpProxy)


              Thanks for any help
              Pius

              Comment


                #8
                1. Download this HttpProxy Implementation:
                http://edwardstx.net/wiki/attach/HttpProxyServlet/ProxyServlet.java

                2. Configure it in web.xml
                Code:
                <servlet>
                    <servlet-name>HttpProxy</servlet-name>
                    <servlet-class>com.logalyze.admin.web.server.ProxyServlet</servlet-class>
                    <init-param>
                      <param-name>proxyHost</param-name>
                      <param-value>127.0.0.1</param-value>
                    </init-param>
                    <init-param>
                      <param-name>proxyPort</param-name>
                      <param-value>8088</param-value>
                    </init-param>
                    <init-param>
                      <param-name>prefixPath</param-name>
                      <param-value>/httpproxy</param-value>
                    </init-param>
                    <init-param>
                      <param-name>proxyPath</param-name>
                      <param-value></param-value>
                    </init-param>
                    <load-on-startup>1</load-on-startup>
                  </servlet>
                
                <servlet-mapping>
                    <servlet-name>HttpProxy</servlet-name>
                    <url-pattern>/httpproxy/*</url-pattern>
                  </servlet-mapping>
                3. Patch executeProxyRequest method to replace absolute URIs
                Code:
                // Replace absolute URLs 
                        String targetURI = "http://"+stringProxyHost+":"+intProxyPort;
                        String sourceURI = httpServletRequest.getContextPath()+stringPrefixPath;
                        response = response.replaceAll(targetURI, sourceURI);
                4. Use relative URI
                Code:
                wsdlURL = GWT.getHostPageBaseURL()+"httpproxy/anything?wsdl";
                ....
                private void loadWSDL(){
                        RPCRequest rpc = new RPCRequest();
                
                        rpc.setTimeout(10000);
                        rpc.setShowPrompt(false);
                        rpc.setWillHandleError(true);
                        
                		XMLTools.loadWSDL(wsdlURL, new WSDLLoadCallback(){
                			public void execute(WebService webService) {
                				System.out.println("WSDL loaded: "+ wsdlURL);
                				SearchService = webService;
                			}
                		}, rpc, true);
                	}
                ...

                Comment

                Working...
                X