Changeset 4038


Ignore:
Timestamp:
Dec 5, 2007, 3:38:10 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #862: Web services server doesn't return exceptions from methods marked as 'void'

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/src/docbook/developerdoc/webservices.xml

    r4024 r4038  
    350350        <listitem>
    351351          <para>Write the routines/methods the service should deploy.</para>
     352         
     353          <warning>
     354            <title>Never return void from methods</title>
     355            <para>
     356              For server-side exceptions to be propagated to the client
     357              the web services method mustn't be declared as <emphasis>void</emphasis>.
     358              We suggest that in cases where there is no natural return value,
     359              the session ID is returned, for example:
     360            </para>
     361           
     362            <programlisting language="java">
     363public String myMethod(String ID, ...more parameters...)
     364{
     365  // ... your code here
     366  return ID;
     367}
     368</programlisting>
     369
     370          </warning>
     371         
    352372        </listitem>
    353373        <listitem>
  • trunk/src/webservices/server/net/sf/basedb/ws/server/ProjectService.java

    r3983 r4038  
    7272      @param ID Id to identify the active session
    7373      @param projectId Id of the project to set as active
     74      @return The Session ID
    7475   */
    75   public void setActiveProject(String ID, int projectId)
     76  public String setActiveProject(String ID, int projectId)
    7677  {
    7778    SessionControl sc = getSessionControl(ID);
     
    8990      }
    9091    }
    91     sc.setActiveProject(project);   
     92    sc.setActiveProject(project);
     93    return ID;
    9294  }
    9395 
  • trunk/src/webservices/server/net/sf/basedb/ws/server/SessionService.java

    r4028 r4038  
    2525
    2626import net.sf.basedb.core.Application;
     27import net.sf.basedb.core.BaseException;
    2728import net.sf.basedb.core.SessionControl;
    2829import net.sf.basedb.info.VersionInfo;
     
    7374      @param comment Comment to be used with the new session
    7475      @param encrypted If encrypted password should be used or not.
     76      @return The Session ID
    7577   */
    76   public void login(String ID, String login, String password, String comment, boolean encrypted)
     78  public String login(String ID, String login, String password, String comment, boolean encrypted)
    7779  {
    7880    SessionControl sc = getSessionControl(ID);
    7981    sc.login(login, password, comment, encrypted);
     82    return ID;
    8083  }
    8184 
     
    8386    Service to logout from BASE
    8487      @param ID Id of the session to logout.
     88      @return The Session ID
    8589   */
    86   public void logout(String ID)
     90  public String logout(String ID)
    8791  {
    8892    SessionControl sc = getSessionControl(ID);
    8993    sc.logout();
     94    return ID;
    9095  }
    9196 
     
    103108    Refresh a session so the time for logging out will be reset.
    104109      @param ID The session id as a string
     110      @return The Session ID
    105111   */
    106   public void refreshSession(String ID)
     112  public String refreshSession(String ID)
    107113  {
    108114    SessionControl sc = getSessionControl(ID);
    109115    sc.updateLastAccess();
     116    return ID;
    110117  }
    111118 
Note: See TracChangeset for help on using the changeset viewer.