hi, I need a session id for the current session. I

Certified Lead Developer

hi,

I need a session id for the current session.

I have tried API but it is giving me null error.

forum.appian.com/.../6621

have any one tried this before.

Thanks
Ankit ...

OriginalPostID-79680

OriginalPostID-79680

  Discussion posts and replies are publicly visible

  • Hi Ankit, it looks like you defined webServiceContext, but never initialized it, so the value is null. Check out docs.oracle.com/.../stateful.htm Example 10-1 Accessing HTTP Session on the Server
    for information on getting the context of the WebServiceContent in order to get the session.
  • +1
    Certified Lead Developer
    i have included WebServiceContent i am getting following error.18:53:46,233 INFO [stdout] (default-short-running-threads-threads - 49) com.appiancorp.suiteapi.common.exceptions.AppianException: Unable to match input for class class com.appiancorp.services.WebServiceContext

    import javax.servlet.http.HttpSession;

    import org.apache.log4j.Logger;

    import com.appiancorp.suiteapi.common.Name;
    import com.appiancorp.suiteapi.content.ContentService;
    import com.appiancorp.suiteapi.process.exceptions.SmartServiceException;
    import com.appiancorp.suiteapi.process.framework.AppianSmartService;
    import com.appiancorp.suiteapi.process.framework.Input;
    import com.appiancorp.suiteapi.process.framework.MessageContainer;
    import com.appiancorp.suiteapi.process.framework.Required;
    import com.appiancorp.suiteapi.process.framework.SmartServiceContext;
    import com.appiancorp.services.*;
    import javax.servlet.http.HttpSession;


    import com.appiancorp.suiteapi.process.palette.PaletteInfo;

    @PaletteInfo(paletteCategory = "Integration Services", palette = "Connectivity Services")
    public class getSessionIdSS extends AppianSmartService {

              private static final Logger LOG = Logger.getLogger(getSessionIdSS.class);
              private final SmartServiceContext smartServiceCtx;
              private String param0;
              private String param1;
              private String sessionID;
              private String return1;
              private WebServiceContext webServiceContext;
              //private ASLIdentity aSLIdentity;
              private ContentService _cs;
              private HttpSession httpSession;
              

              @Override
              public void run() throws SmartServiceException {
                        
                         httpSession=(HttpSession)webServiceContext.getSession();
                        
                         System.out.println(httpSession.getId());
                         sessionID=httpSession.getId();
                        }

              public getSessionIdSS(SmartServiceContext smartServiceCtx, ContentService _cs, WebServiceContext webServiceContext) {
                        super();
                        this.smartServiceCtx = smartServiceCtx;
                        this._cs=_cs;
                        this.webServiceContext=webServiceContext;
              }
              
              

              public void onSave(MessageContainer messages) {
              }

              public void validate(MessageContainer messages) {
              }

              @Input(required = Required.OPTIONAL)
              @Name("param0")
              public void setParam0(String val) {
                        this.param0 = val;
              }

              @Input(required = Required.OPTIONAL)
              @Name("param1")
              public void setParam1(String val) {
                        this.param1 = val;
              }

              @Name("SessionID")
              public String getSessionID() {
                        return sessionID;
              }

              @Name("return1")
              public String getReturn1() {
                        return return1;
              }

    }



    error:

    18:53:46,233 INFO [stdout] (default-short-running-threads-threads - 49) com.appiancorp.suiteapi.common.exceptions.AppianException: Unable to match input for class class com.appiancorp.services.WebServiceContext