Wednesday, September 30, 2009

Inter operating Apache Sandesah2 with WCF

Recently I have been working on interoperating WCF with the Apache Sandesha2. The good news is all the plain RM scenarios pass with some small fixings. Here is an sample client which can be used to invoke the wcf services available at

First I generated the code for the given wsdl with wsdl2java tool with the following arguments

-u -ap -uw


-o target/generated-code



Then we can simple invoke the service using the following client code.

// creating an configuration context which contains sandesah2 and addressing
ConfigurationContext configurationContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem("target" + File.separator +
"" +
File.separator + "repository");

EchoStringServiceCustomBinding_IEchoString9Stub stub = new EchoStringServiceCustomBinding_IEchoString9Stub(configurationContext,
// this is to send messages through tcp mon

// setting the correct addressing , soap and rm versions
stub._getServiceClient().getOptions().setProperty(AddressingConstants.WS_ADDRESSING_VERSION, AddressingConstants.Submission.WSA_NAMESPACE);
stub._getServiceClient().getOptions().setProperty(SandeshaClientConstants.RM_SPEC_VERSION, Sandesha2Constants.SPEC_VERSIONS.v1_1);

//wcf does not support make connections so disable it
Parameter sandeshaPolicyBeanParam = stub._getServiceClient().getAxisConfiguration().getParameter(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
if (sandeshaPolicyBeanParam != null) {
SandeshaPolicyBean sandeshaPolicyBean = (SandeshaPolicyBean) sandeshaPolicyBeanParam.getValue();


PingRequestBodyType pingRequestBodyType = new PingRequestBodyType();
pingRequestBodyType.setSequence("Sequence 1");
PingResponseBodyType pingResponseBodyType = null;
String responseString = "";
for (int i = 0; i < 3; i++) {
responseString += "testparam";
pingResponseBodyType = stub.echoString(pingRequestBodyType);

// after sending the messages we can close and terminate the sequence

//wait until terminate sequence messge is send

1 comment:

Khlouf said...

Hi Amila,

I'm trying to use Axis2/Sandesha2 with the JDBC implementation of the StorageManager.

I have to make services reliables for the followings tests cases

1 Client UP - Server Down
- Client call a service
- Start the server
- The server answer the client

2 Client UP - Server Down
- Client call a service
- Shutdown the client
- Start the server
- Start the client
- The server answer the client

Could Sandesha2 answer this kind of demand ?

I have some issues with the actual version of Sandesha2. Could you please send me your samples and implementation of Sandesha2 ?

Best regards,