Hi,

I am trying to write "synchronous dual channel blocking service
invocation." client code.

While running the code i am getting the error:
"org.apache.axis2.AxisFault: Unable to engage module : addressing
    at
org.apache.axis2.client.ServiceClient.engageModule(ServiceClient.java:363)
    at
edu.in.siemens.webservice.client.HelloWorldClient.main(HelloWorldClient.java:49)"

*Ref*:http://axis.apache.org/axis2/java/core/docs/userguide-samples.html

*Client Code:*
package edu.in.siemens.webservice.client;

import java.io.StringWriter;

import javax.xml.namespace.QName;
import javax.xml.stream.XMLOutputFactory;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.AxisCallback;
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.MessageContext;

public class HelloWorldClient {
    private static EndpointReference targetEPR = new EndpointReference(
            "http://localhost:8080/axis2/services/UserGuideSampleService";);

    public static void main(String[] args) throws Exception {
        ServiceClient client = new ServiceClient();

        try {

            OMFactory factory = OMAbstractFactory.getOMFactory();
            OMNamespace namespace = factory.createOMNamespace(
                    "http://example1.org/example1";, "example1");

            OMElement method = factory.createOMElement("sayHello",
namespace);
            OMElement value = factory.createOMElement("personToGreet",
                    namespace);

            value.addChild(factory.createOMText(value, "Ashish Soni"));
            method.addChild(value);

            Options options = new Options();
            options.setTo(targetEPR);
            options.setUseSeparateListener(true);
            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

            client.engageModule(Constants.MODULE_ADDRESSING);
            client.setOptions(options);
            OMElement result = client.sendReceive(method);

            StringWriter writer = new StringWriter();
            result.serialize(XMLOutputFactory.newInstance()
                    .createXMLStreamWriter(writer));
            writer.flush();
            System.out.println(writer.toString());
        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            try {
                client.cleanup();
            } catch (AxisFault axisFault) {
                //
            }
        }
    }
}

Is any specific setup is required to run the client code.
-- 
Ashish Soni
Bangalore(Karnataka)- 560076

"A dream becomes a goal when action is taken toward its achievement."

Reply via email to