Calling a service with a workspace context from a Java based client or JUnit testcase
You can specify a workspace context when you call a WebSphere Commerce service from a Java based client, or a JUnit test case.
About this task
Note: The Management Center Web application includes business context data by default
in its service requests. You do not need to modify the Management Center to include this
data.
Procedure
- Create a workspace, task, or task group to use for testing.
-
Include Java code similar to the following sample (from a JUnit testcase) to set the business
context in your client code:
In the preceding example:// set the business context intent businessContext.setIntent("Authoring"); // add the workspace context data to the business context ContextDataType contextData = CommerceFoundationFactory.eINSTANCE.createContextDataType(); contextData.setName("workspace.name"); contextData.setValue("W_10001"); businessContext.getContextData().add(contextData); contextData = CommerceFoundationFactory.eINSTANCE.createContextDataType(); contextData.setName("workspace.taskGroup"); contextData.setValue("G_10001"); businessContext.getContextData().add(contextData); contextData = CommerceFoundationFactory.eINSTANCE.createContextDataType(); contextData.setName("workspace.task"); contextData.setValue("T_10002"); businessContext.getContextData().add(contextData);
- W_10001 is the workspace name
- G_10001 is the task group name
- T_10002 is the task name