Announcement

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

    RestHandler and AXIS servlets

    SmartGWTEE 2.5 eval

    The datasources seem to work nicely for our web UI client. Now we are trying to get our other web services to integrate nicely with the SmartGWT server and leverage all the cool stuff in the datasources (ds.xml files).

    It seems like RestHandler and AXIS servlets are the way to go but we are having some issues getting them to work.

    1) Where is the AxisServlet? I see it mentioned in a document here:
    http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/docs/ServletDetails.html but I'm not able to locate the actual servlet anywhere else in the docs. Does it exist?

    2) We are trying to get the example for the RestHandler working but are running into errors. We managed to load the servlet successfully and we are able to hit it in the browser, but we get an error. The details are as follows:

    Code:
    <servlet>
           <servlet-name>RESTHandler</servlet-name>
           <servlet-class>com.isomorphic.servlet.RESTHandler</servlet-class>
           <init-param>
               <param-name>defaultDataFormat</param-name>
               <param-value>json</param-value>
           </init-param>
           <init-param>
               <param-name>wrapJSONResponses</param-name>
               <param-value>false</param-value>
           </init-param>
           <init-param>
               <param-name>wrapJSONResponses</param-name>
               <param-value>false</param-value>
           </init-param>
       </servlet>
       <servlet-mapping>
           <servlet-name>RESTHandler</servlet-name>
           <url-pattern>/restapi/*</url-pattern>
       </servlet-mapping>
    URL
    http://127.0.0.1:8080/MyWebApp/restapi/?_dataSource=deviceType

    This generates the following error:
    Code:
    <BR>com.isomorphic.servlet.RESTHandler top-level exception<BR>
    <PRE>
    java.lang.StackOverflowError
    	at sun.nio.cs.SingleByteEncoder.encodeArrayLoop(SingleByteEncoder.java:91)
    	at sun.nio.cs.SingleByteEncoder.encodeLoop(SingleByteEncoder.java:130)
    	at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:544)
    	at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:252)
    	at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:106)
    	at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:116)
    	at java.io.OutputStreamWriter.write(OutputStreamWriter.java:203)
    	at java.io.Writer.write(Writer.java:140)
    	at org.apache.log4j.helpers.QuietWriter.write(QuietWriter.java:48)
    	at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:302)
    	at org.apache.log4j.WriterAppender.append(WriterAppender.java:160)
    	at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
    	at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
    	at org.apache.log4j.Category.callAppenders(Category.java:206)
    	at org.apache.log4j.Category.forcedLog(Category.java:391)
    	at org.apache.log4j.Category.debug(Category.java:260)
    	at com.isomorphic.log.Logger.debug(Logger.java:406)
    	at com.isomorphic.datasource.DSRequest.registerFreeResourcesHandler(DSRequest.java:3080)
    	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1142)
    	at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:282)
    	at com.isomorphic.sql.SQLDataSource.executeCustom(SQLDataSource.java:240)
    	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1174)
    	at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:282)
    	at com.isomorphic.sql.SQLDataSource.executeCustom(SQLDataSource.java:240)
    	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1174)
    .... the last couple of lines over and over and over again... Stack Overflow...
    I'm pretty sure we are hitting the servlet since we get a different error if we try to pass a dataSource param in the URL that doesn't exist. Our DataSource ds.xml is as follows:

    Code:
    <!-- Auto-generated from database table DEVICETYPE -->
    
    <DataSource 
    	schema="***masked***"
    	dbName="Oracle"
    	tableName="DEVICETYPE_CORE"
    	titleField="DEVICE_TYPE_NAME"
    	infoField="DESCRIPTION"
    	ID="deviceType"
    	serverType="sql"
    >
    	<fields>
    		<field name="PK" type="sequence" sequenceName="DEVICETYPE_CORE_SEQ" hidden="true" primaryKey="true"></field>
    		<field name="DEVICE_TYPE_NAME" type="text" unique="true" title="Type"></field>
    		<field name="DESCRIPTION" type="text" title="Description"></field>
    	</fields>
    </DataSource>
    Admittedly, I know little about JSON. We are simply trying to see what URL we would need to simply "fetch" a record or all the records from this DataSource (there are only 5 or so in the DB).

    We've looked at RestHandler and RestDataSource and the QuickStart. Any other suggestions?

    #2
    The server is getting confused because the request doesn't contain enough information for it to work out what type of operation you want it to perform (fetch, update, etc). The REST protocol supported by our RESTHandler servlet is documented here: http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/data/RestDataSource.html

    The easiest way to see a well-formed REST request that SmartGWT Server will process is to create a client-side RestDataSource, issue an operation on it, and use Fiddler or something similar to have a look what goes over the wire.

    Comment


      #3
      As always, thanks for the speedy response.

      We have looked at that particular example ad nausea. We tried including more params in the url (including the operation type). What we found is that it didn't matter what else was in the url (even if they were params that were completely made up or invalid). Simply having the one param specifying the dataSource to use always caused the Stack Overflow error so we removed all params except for that one in attempts to debug what would be causing it. We figured once we got beyond that point, we'd actually look at specific operations, fields, and values.

      Comment


        #4
        Since you're saying the RestHandler is non-functional, this appears to be a broken install. You may have .jar files from different versions of SmartGWT present, or multiple copies of the same .jar in the classpath in different folders.

        A quick way to verify this (for your own sanity) would be to just open up one of the sample projects included in the SDK in a fresh Eclipse workspace and direct your browser to hit the RestHandler (just type the request into the URL bar).

        About AxisServlet - it's an Apache class that's part of Axis:

        Code:
            <servlet>
                <servlet-name>AxisServlet</servlet-name>
                <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
            </servlet>
        When this is configured in web.xml, the WSDL service described by SmartClientOperations.wsdl will be active. This is a generic WSDL service that allows access to any .ds.xml DataSource stored on the server.

        You can also build DataSource-specific services if you find that some tool or application you are integrating with needs more specific types or has some other special requirements about the WSDL it integrates with. In this case, inside your Axis-generated stub code, you will extract data from Axis-generated classes and use the server-side DataSource API to execute operations. The pattern is similar to DataSource usage in a command-line Java app, except you don't need to worry about webroot as described in that document.

        Comment


          #5
          Will check this out tonight/tomorrow. Thanks again.

          Comment


            #6
            Got the axis jar (and related dependent jars) loaded and the AxisServlet (1.4) up and running (so I think).

            Where can I find the SmartClientOperations.wsdl? I have the SmartGWTEE 2.5 eval.

            Comment


              #7
              Nm. Found it. It looks like it has moved in the last couple of years?

              For anyone interested:
              Look in the smartgwt.jar/com/smartclient/public/sc/system/schema

              Comment

              Working...
              X