SmartObject execution error.

  • 17 June 2009
  • 4 replies
  • 3 views

Badge +4

While execution of smartobject getting an error ""Exception of type 'SourceCode.SmartObjects.Client.SmartObjectException' was thrown.""


I have done following things:


1) Created Service object from SAP method.


2) Depends upon service object created smartobject.


3) This smartobject trying to execute in the asp.net codebehind but giving an error.


string smartObjectName = "ProjectDetails";


string methodName = "Service1_Z_K2_GEN_PROJ_INFO";


SourceCode.SmartObjects.Client.

SmartObject smartObject = smartObjectServer.GetSmartObject(smartObjectName);


int projectNumber = 72;


smartObject.ListMethods[0].InputProperties[

"p_PROJ_RESP_NUM"].Value = projectNumber.ToString();


smartObject.MethodToExecute = methodName;

SmartObjectList projectList = smartObjectServer.ExecuteList(smartObject); ----------------- At this line getting an error  "Exception of type 'SourceCode.SmartObjects.Client.SmartObjectException' was thrown.""


foreach (SmartObject so in projectList.SmartObjectsList)


{


    string s = so.Properties[1].Value;


}


Is anybody aware of this issue?


 


 


4 replies

Badge

I wanted to also add myself to the list of those experiencing this exception (Exception of type 'SourceCode.SmartObjects.Client.SmartObjectException' was thrown.).  I haven't found a solution to it.  In my case, the code snippet below is trying to execute a "List" method that is referenced by the "Broker" smart object.  The implementation of this List method is done via a custom smart object service instance that I successfully configured in the BrokerManagement app on the K2 server.  I also able to successfully reference the service's method from the Broker smart object method wizard in the designer.  No compile time errors.  Any ideas on how to troubleshoot?  Thanks.


 server.CreateConnection();
 server.Connection.Open(connStr.ToString());


 SmartObject smartObject = server.GetSmartObject("Broker");
 smartObject.MethodToExecute = "List";


 SmartObjectList smoBrokers = server.ExecuteList(smartObject);   // throws exception on this line


 foreach (SmartObject smo in smoBrokers.SmartObjectsList)
 {
         Broker b = new Broker();
         b.ID = Convert.ToInt32(smo.Properties["ID"].Value);
         b.Name = smo.Properties["Name"].Value;
         brokers.Add(b);
 }

Badge +6

Do you have any resulotion to this? I am also having the same issue.

Badge +4
Hi Guys

So I was having the same problem as you all.
I implemented the following catch clause after the executescalar being in the try section of the clause.

catch(SmartObjectException soEx) {

StringBuilder sb = new StringBuilder();

foreach(SmartObjectExceptionData soExData in soEx.BrokerData) {

sb.Append("Service: ");

sb.AppendLine(soExData.ServiceName);

sb.Append("Service Guid: ");

sb.AppendLine(soExData.ServiceGuid);

sb.Append("Severity: ");

sb.AppendLine(soExData.Severity.ToString());

sb.Append("Error Message: ");

sb.AppendLine(soExData.Message);

sb.Append("InnerException Message: ");

sb.AppendLine(soExData.InnerExceptionMessage);

throw new Application Exception(sb.toString(), soEx);

}


This will give you the actual error that the smartobject is returning. Mine was a datetime value being in the wrong format.
so if you selected a date lower than 12 it worked, anything higher and it failed as obviously there are only 12 months in a year ;)

I hope this helps some people!
Badge +11

Hi SteveB  your Prophecy came true!!!!!!


Thanx a Lot Steve; it really helped me.


Many thanks

Reply