Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Insert excerpt
Data Integration Samples
Data Integration Samples
nopaneltrue

...

This service contains a single query/operation named showAllOffices, which returns all the office branches in a company.

Secure service client: When using a service client to access a secured data service, it must follow special steps in creating a secured connection to the service. The following code snippet is taken from the Axis2 service client used to access our sample secure data service.

Code Block
String epr = "https://" + HOST_IP + ":" + HOST_HTTPS_PORT + "/services/SecureDataService";
System.setProperty("javax.net.ssl.trustStore", (new
File(CLIENT_JKS_PATH)).getAbsolutePath());
ConfigurationContext ctx = ConfigurationContextFactory.
createConfigurationContextFromFileSystem(null, null);
SecureDataServiceStub stub = new SecureDataServiceStub(ctx, epr);
ServiceClient client = stub._getServiceClient();
Options options = client.getOptions();
client.engageModule("rampart");
options.setUserName("admin");
options.setPassword("admin");
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,
loadPolicy(SECURITY_POLICY_PATH));

...

Enable security for the data service SecureDataService . Select UsernameToken in the basic scenario. Here we are simply enabling username/password based authentication for the data service. Select everyone as the user group. For step-by-step instructions on service-level security setting, refer to  Security for Web Services /wiki/spaces/EI6xx/pages/49616509.

Running the sample

The sample service can be run using the TryIt tool, which is bundled with the WSO2 Data Services Server, or a code-generated java client sample as discussed in the Data Services Clients section.

...