Skip to main content
Nintex Community Menu Bar

Hello everyone,

 

I have the same question posed in this thread, which was unfortunately left unanswered:  Implementing custom service object: reach access to service instance configuration settings?

 

To restate, I'm creating a custom static service broker for our K2 project.  In the service broker .cs file, in the GetConfigSection I have the following code:

 

this.Service.ServiceConfiguration.Add("WebService URL", true, String.Empty);this.Service.ServiceConfiguration.Add("Client ID", true, String.Empty);

 In the service object itself I need to access both the WebService URL and the Client ID values.  Following the 400.BLR module handbook, and the source code for another custom service broker found in the Underground, I've added the following code to the service object:

 

private ServiceConfiguration _serviceConfig;public ServiceConfiguration ServiceConfiguration{     get { return _serviceConfig; }     set { _serviceConfig = value; }}

 And then to access the values from the ServiceConfiguration I call:

 

filterService.Url = this.ServiceConfigurationf"WebService URL"].ToString();

 All this compiles fine and the K2 SmartObject Tester is able to register it and create a SmartObject with it.  However, when I attempt to run the SmartObject I get an "Object reference not set to an instance of an object" error at the line where I call ServiceConfigurationo"WebService URL"]. 

 

Am I missing a step here?

 

Any help would be appreciated.  Thank you!

The most obvious observation from the code is that as you added your configuration settings to this.Service.ServiceConfiguration array, shouldn't you been accessing the settings from this level and NOT this.ServiceConfiguration.

 

So replace:

filterService.Url = this.ServiceConfigurationn"WebService URL"].ToString();

 

with:

filterService.Url = this.Service.ServiceConfigurationo"WebService URL"].ToString();


Hi ChrisWillard,


 


Where the information provided by “KennyC” able to resolve you issue? 


 If the information “KennyC” provided resolved your issue as needed, can the post be marked as Solution. {The post that helped}


Let me know if there is something you are still unclear about.


 


Regards


Quintin 


 


Sorry, no, it didn't. I'm not trying to access the ServiceConfiguration inside the service broker, I'm trying to access it in the service object.

 

I've temporarily solved the issue by setting the service objects ServiceConfiguration value in the service broker right after instantiating the service object. This is done in the Execute function with the following code

 

serviceObject.ServiceConfiguration = this.Service.ServiceConfiguration;

 

This isn't how we're supposed to do it according to the 400.BLR documentation, however, so I feel like this is a temporary fix. If anyone knows the correct way of doing this I'd greatly appreciate any suggestions.


Hi,Chris. Any update on this thread?


Just in case anyone finds this in the future.

I found that in the Static Broker class that the property had to be named "ServiceConfiguration" in order to work. I originally had it named something different and it wasn't getting populated by the K2 infrastructure. Once I changed it to that specific name, it worked. 

 

 // K2 automatically populates this property at runtime with the information from the Service Instance
public ServiceConfiguration ServiceConfiguration { get; set; }

Reply