Call Smartobject method inside a web service

  • 7 August 2008
  • 2 replies
  • 3 views

Badge

Hello,

I would like to call several smartobject methods from within a web service in order to achieve cascading drop-down list boxes within InfoPath.  I have not been able to dig up anything thus far.  Does anyone have a good explanation on how to execute smartobject methods with code ? What needs to be referenced?

 Thank in advance for your help!


2 replies

Badge +8

Hey, you can use code to access smart object as long as you can access the K2 api and have active connection to k2 server. Below is the code snippet

  SourceCode.HostClientAPI,
SourceCode.SmartObjects.Client

string m_strSOConnManagedUsers = "Server=server;Port=5555;AutoAlias=False;SmartObjects=Tasks";               
                string strSelectCmd = "Smartobject.GetList";               
                SourceCode.Data.SmartObjectsClient.SOConnection oConn = new                       SourceCode.Data.SmartObjectsClient.SOConnection(m_strSOConnManagedUsers);


                SourceCode.Data.SmartObjectsClient.SOCommand oCmd = new SourceCode.Data.SmartObjectsClient.SOCommand(strSelectCmd, oConn);
                SourceCode.Data.SmartObjectsClient.SODataReader oRdr = null;               
                oCmd.CommandType = System.Data.CommandType.StoredProcedure;               
                SourceCode.Data.SmartObjectsClient.SOParameter oParam = new SourceCode.Data.SmartObjectsClient.SOParameter("@Parameter1", "Value");
                SourceCode.Data.SmartObjectsClient.SOParameter oParam1 = new SourceCode.Data.SmartObjectsClient.SOParameter("@Parameter2", "value");
                oCmd.Parameters.Add(oParam);
                oCmd.Parameters.Add(oParam1);               
                oRdr = oCmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                string m_strPrefix = "";               
                if (oRdr != null)
                {
                    if (oRdr.HasRows)
                    {
                       
                        while (oRdr.Read())
                        {

// do stuff here with data
                        }
                    }
                }
               
                oRdr.Close();
            }
            catch (Exception ex)
            {

                // Add exception handling code here..
            } 

 

Full source is available in k2 developer ref...check it out 

HTH

 

Badge +9

There are many code samples around topics like this and other K2 APIs contained within the Developer's Reference.  You can find it here:


     http://k2underground.com/files/folders/technical_product_documents/entry23558.aspx


 

Reply