You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by Kai Wei <we...@gmail.com> on 2004/12/01 05:34:58 UTC

ws-addressing: how can i make it work?

Hi,

I checked out the ws-addressing source from the CVS, successfully
built it, and followed the instructions in the ShortTutorial.txt file
that comes along with the checkout to build a simple echo service.

What I want is, I send a request to echo2 service, and echo2 should
forward this request to another service, echo. But it seems echo2
service does not do the forwarding, but services the request itself.

The code is pasted below. What am I doing wrong? (I did modify
deploy.wsdd to add an addressing handler to echo2)

-Vince

import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.message.addressing.Action;
import org.apache.axis.message.addressing.To;
import org.apache.axis.message.addressing.AddressingHeaders;
import org.apache.axis.message.addressing.Constants;
import org.apache.axis.message.addressing.EndpointReference;
import org.apache.axis.types.URI;

/**
 * Class : VersionClient
 */
public class Echo2Tester
{

    static String url = "http://localhost:8080/axis/services/Echo2";

    public static void main(String[] args) throws Exception
    {
        Service service = new Service();
        Call call = (Call) service.createCall();
        AddressingHeaders headers = setUpAddressing();
        call.setProperty(Constants.ENV_ADDRESSING_REQUEST_HEADERS, headers);
        call.setTargetEndpointAddress(new java.net.URL(url));
        call.setOperationName(new QName(
                "http://localhost:8080/axis/services/Echo", "echo"));
        String ret = (String) call.invoke(new Object[]
        {args[0]});
        System.out.println("Sent '" + args[0] + "', got '" + ret + "'");
    }

    private static AddressingHeaders setUpAddressing() throws Exception
    {
        AddressingHeaders headers = new AddressingHeaders();
        To to = new To(new URI("http://localhost:8080/axis/services/Echo"));
        headers.setTo(to);
        Action a = new Action(new URI("urn:action"));
        headers.setAction(a);
        EndpointReference epr = new EndpointReference("http://www.apache.org");
        headers.setFaultTo(epr);
        return headers;
    }
}