2 Replies Latest reply on Oct 20, 2005 4:24 AM by dabrigo

    WebRowSet parameter

    dabrigo

      Hi folks,
      does anyone know how to use the WebRowSet class as a parameter (either input or output) in a Webservice? :banghead:
      let's say something like this:

      public interface TestWRS extends Remote {
       WebRowSet getRowSet() throws RemoteException;
      }
      
      public class TestWRSEndpoint implements TestWRS {
       public WebRowSet getRowSet() throws RemoteException {
       WebRowSet wrs = new WebRowSetImpl();
       // ...more code here to read data into the rowset...
       return wrs;
       }
      }
      

      i saw in the documentation of JWSDP that it should work automatically when using wscompile, but it throws an error saying:
      error: Collection types are not supported in literal mode - Type: "java.util.Map"

      Thanks! :beerchug:

        • 1. Re: WebRowSet parameter
          thomas.diesler

          The error says it. java.util.Map is not allowed by JAXRPC-1.1. See the spec for details of allowed types.

          The reason is probably that not every language that implement web services has a notion of maps.

          • 2. Re: WebRowSet parameter
            dabrigo

            ok but why is it throwing an error about java.util.Map if it's not used?
            BTW, by now i solved my problem passing the WebRowSet as an XML String, here is a test method i wrote:

            public String getRowSet() throws RemoteException {
             StringWriter sw = new StringWriter();
             WebRowSet wrs;
             Connection conn;
             ResultSet rs;
            
             try {
             Class.forName("org.postgresql.Driver");
             } catch (ClassNotFoundException e) {
             throw new RemoteException("Driver exception", e.getCause());
             }
            
             try {
             conn = DriverManager.getConnection("jdbc:postgresql://...", "...", "...");
             } catch (SQLException e) {
             throw new RemoteException("Connection exception", e.getCause());
             }
            
             try {
             Statement st = conn.createStatement();
             rs = st.executeQuery("SELECT * FROM...");
             } catch (SQLException e) {
             throw new RemoteException("SQL exception", e.getCause());
             }
            
             try {
             wrs = new WebRowSetImpl();
             wrs.populate(rs);
            
             conn.close();
             wrs.writeXml(sw);
             return sw.toString();
             } catch (Exception e) {
             throw new RemoteException("WebRowSet exception", e.getCause());
             }
            }