Call Smartobject method inside a web service

Last post 08-08-2008, 6:26 PM by Bob. 2 replies.
Sort Posts: Previous Next
  •  08-07-2008, 10:32 AM 25418

    Call Smartobject method inside a web service

    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!

  •  08-07-2008, 11:55 AM 25420 in reply to 25418

    Re: Call Smartobject method inside a web service

    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

     

  •  08-08-2008, 6:26 PM 25441 in reply to 25420

    Re: Call Smartobject method inside a web service

    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

     


    The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
View as RSS news feed in XML