WSO2 Web Services Framework for C++ -Samples Guide

Once you have installed the samples, you can run them from, WSFCPP_HOME/bin/samples/cpp. For example, to run the echo sample, execute the echo binary found in WSFCPP_HOME/bin/samples/cpp/echo.

Modifying the Samples

You always can modify the samples by editing the respective .cpp files found in the sub-directories of WSFCPP_INSTALL_DIR/samples. For instance, to modify the echo_security client edit echo_security.cpp found in WSFCPP_INSTALL_DIR/samples/echo.
Once you have finished editing, re-build WSO2 WSF/C++ in the case of MS Windows or, run 'make examples' for Linux from the WSFCPP_INSTALL_DIR.

Re-building Samples (MS Windows)

Initialize environment for using Microsoft Visual Studio tools, by running vcvars32.bat (which is found in, MS_VISUAL_STUDIO_INSTALL_DIR/VC/bin). Then,

  1. cd WSFCPP_INSTALL_DIR\samples
  2. Run 'nmake dist -f samples.mk AUTOCONF=..\configure.in'

Using Command-Line Interface

Some samples do have a command-line interface where you can specify certain parameters at runtime. For help in using the command-line interface run the sample with a -h switch. (ex:- Windows: 'echo.exe -h', Linux: './echo -h').

Echo Samples

echo

Echo client with WS-Addressing, and iterative invocation. Set the following variables to match your case.

  1. end_point[Line 15]. default: http://localhost:9090/axis2/services/echo
  2. iterations[Line 16]. default: 2
  3. log_file_name[Line 35]. default: echo.log
  4. log_level[Line 35]. default: AXIS2_LOG_LEVEL_TRACE Command-Line Interface: Yes

echo_blocking

Echo client with most basic options. Set the following variables to match your case.

  1. end_point[Line 11]. default: http://localhost:9090/axis2/services/echo
  2. log_file_name[Line 14]. default: echo_blocking.log
  3. log_level[Line 14]. default: AXIS2_LOG_LEVEL_TRACE
  4. Command-Line Interface: No

echo_blocking_dual

Echo client using seperate listner, and different ReplyTo. Set the following variables to match your case.

  1. end_point[Line 14]. default: http://localhost:9090/axis2/services/echo
  2. reply_to[Line 15]. default: http://localhost:6060/axis2/services/
  3. __ANONYMOUS_SERVICE__/__OPERATION_OUT_IN__
  4. log_file_name[Line 37]. default: echo_blocking_dual.log
  5. log_level[Line 37]. default: AXIS2_LOG_LEVEL_TRACE
  6. Command-Line Interface: Yes
  7. known issue -> This sample sometime fails due to a threading issue.

echo_blocking_addr

Echo client with WS-Addressing. Set the following variables to match your case.

  1. end_point[Line 11]. default: http://localhost:9090/axis2/services/echo
  2. log_file_name[Line 14]. default: echo_blocking_addr.log
  3. log_level[Line 14]. default: AXIS2_LOG_LEVEL_TRACE
  4. Command-Line Interface: No

echo_blocking_soap11

Echo client with SOAP 1.1 support. Set the following variables to match your case.

  1. end_point[Line 11]. default: http://localhost:9090/axis2/services/echo
  2. log_file_name[Line 14]. default: echo_blocking_soap11.log
  3. log_level[Line 14]. default: AXIS2_LOG_LEVEL_TRACE
  4. Command-Line Interface: No

echo_rest

Echo client with REST style invocation support. Set the following variables to match your case.

  1. end_point[Line 11]. default: http://localhost:9090/axis2/services/echo
  2. log_file_name[Line 14]. default: echo_rest.log
  3. log_level[Line 14]. default: AXIS2_LOG_LEVEL_TRACE
  4. Command-Line Interface: No

echo_non_blocking

Echo client with non-blocking (asynchronous) operations. Set the following variables to match your case.

  1. end_point[Line 44]. default: http://localhost:9090/axis2/services/echo
  2. timeout[Line 45]. default: 10000
  3. log_file_name[Line 67]. default: echo_non_blocking.log
  4. log_level[Line 67]. default: AXIS2_LOG_LEVEL_TRACE
  5. Command-Line Interface: Yes

echo_non_blocking_dual

Echo client using seperate listner, and different ReplyTo in a non-blocking (asynchronous) operation. Set the following variables to match your case.

  1. end_point[Line 40]. default: http://localhost:9090/axis2/services/echo
  2. reply_to[Line 53]. default: http://localhost:6060/axis2/services/
  3. __ANONYMOUS_SERVICE__/__OPERATION_OUT_IN__
  4. timeout[Line 72]. default: 10000
  5. log_file_name[Line 43]. default: echo_non_blocking_dual.log
  6. log_level[Line 43]. default: AXIS2_LOG_LEVEL_TRACE
  7. Command-Line Interface: No
  8. Known issue -> This sample sometimes fails due to a threading issue.

echo_security

Echo client with WS-SecurityPolicy. Set the following variables to match your case.

  1. end_point[Line 14]. default: http://localhost:9090/axis2/services/sec_echo
  2. client_repo[Line 15]. default: client_repo/
  3. policy_file[Line 16]. default: policy.xml
  4. log_file_name[Line 41]. default: echo_security.log
  5. log_level[Line 41]. default: AXIS2_LOG_LEVEL_TRACE
  6. Command-Line Interface: Yes
  1. * Please note that the echo_security sample will not work unless you set the client_repo, and the policy_file variables, and modify the sample.
  2. * Make sure you have run, Linux: RAMPART_SAMPLES_DIR/rampart/client/sec_echo/deploy_client_repo.sh or Windows: RAMPART_SAMPLES_DIR\client\sec_echo\deploy_client_repo.bat.

Accessing Yahoo WebService API

yahoo

A client assessing Yahoo search using REST. Set the following variables to match your case.

  1. log_file_name[Line 14]. default: yahoo_rest_search.log
  2. log_level[Line 14]. default: AXIS2_LOG_LEVEL_TRACE
  3. Command-Line Interface: No
  4. This sample sometimes does not respond because the yahoo service is not responding for certain requests.

Accessing Google WebService API

google

A client assessing Google SOAP 1.1 search. Set the following variables to match your case.

  1. log_file_name[Line 14]. default: google_client.log
  2. log_level[Line 14]. default: AXIS2_LOG_LEVEL_TRACE
  3. google_api_key[Line 38]. default: 00000000000000000000000000000000
  4. Command-Line Interface: No
  5. A valid api key would return a response, and an invalid key would return a fault. The default key is invalid. The google SOAP search API is now deprecated and therefore you cannot obtain a google key to use this service anymore. However if you already have a google key, you can try this sample.

Accessing Flickr WebService API

flickr

A client assessing Flickr photo search. Set the following variables to match your case.

  1. log_file_name[Line 14]. default: flickr_client.log
  2. log_level[Line 14]. default: AXIS2_LOG_LEVEL_TRACE
  3. flickr_api_key[Line 27]. default: 00000000000000000000000000000000
  4. Command-Line Interface: No
  5. A valid api key would return a response, and an invalid key would return a fault. The default key is invalid.

MTOM / Base64 Attachments

mtom

Client for uploading JPEG image files using MTOM. Set the following variables to match your case.

  1. end_point[Line 16]. default: http://localhost:9090/axis2/services/mtom
  2. file_name[Line 17]. default: resources/axis2.jpg
  3. log_file_name[Line 40]. default: mtom.log
  4. log_level[Line 40]. default: AXIS2_LOG_LEVEL_TRACE
  5. Command-Line Interface: Yes

Math Client

math

Client providing four mathematical operations - add: Addition - sub: Subtraction - mul: Multiplication - div: Division

Set the following variables to match your case.

  1. end_point[Line 14]. default: http://localhost:9090/axis2/services/math
  2. operation[Line 15]. default: add
  3. param1[Line 16]. default: 40
  4. param2[Line 17]. default: 8
  5. log_file_name[Line 45]. default: math_blocking.log
  6. log_level[Line 45]. default: AXIS2_LOG_LEVEL_TRACE
  7. Command-Line Interface: Yes

Notify Client

notify

Client demonstrating one-way operation. Set the following variables to match your case.

  1. end_point[Line 11]. default: http://localhost:9090/axis2/services/notify
  2. log_file_name[Line 14]. default: notify.log
  3. log_level[Line 14]. default: AXIS2_LOG_LEVEL_TRACE
  4. Command-Line Interface: No

Security Policy Samples

secpolicy

Set of scenarios that be used to generate various policy files and invoke the echo_security sample. There are three invocation models. The scripts for running the security senarios are located in the directory <WSFCPP_HOME>/samples/bin/security. There you will find the scripts run_all.sh, deploy.sh deploy_client_repo.sh and test_scen.sh shell scripts. On windows, use the bat files with similar names.
In the directory <WSFCPP_HOME>/samples/src/c/rampartc/ you will find the rampartc samples. We use the same security policy file used in rampartc for demonstrating the WS security in WSF/CPP as well. in the secpolicy directory, there are many security scenarios with corresponding folders named scenario1 scenario2 ....

The sample used is the sec_echo client in the samples/bin directroy. By changing the policy file and service configuration file, various security scenarios can be modeled. Before running the samples, you need to run the deploy_client_repo.sh ( or bat ) file.

Seven scenarios are provided demonstrating various possibilities.

pSample Services

These samples are found under the directory WSFCPP_INSTALL_DIR/examples/services directory

Echo Service

Math Service

This service consist of four mathamatical operations

MTOM Service

This service receives and send a SOAP message with a MTOM optimized binary attachment.e - Default service endpoint http://localhost:9090/axis2/services/mtom

Monitoring Payload

tcpmon

You may monitor the exchanged payload using the tcpmon utility provided in WSF/C. This tool can be found in [wsf_c/axis2c/tools/tcpmon].