简体   繁体   中英

Axis2 Web Service - Versioing

I'm new to web services. I have developed a sample web service as shown below.

I'm trying to add a new field in the Data, say boolean sucess; . (Just to learn the backward compatibility)

When i add the new field, as i expected the service invocation fails from client stub.

How do i maintain different version of services. what all options i have?

I have gone through many articles on the net (unfortunately there are no examples. :(). And few options are

1) writing different operation in the class with the new output. This i understood.

2) Have versioning for the service. Like services/ version1 /SumAndMult, services/ version2 /SumAndMult

How do i achieve the second option? What is the idea behind this option? To maintain copy of the service classes?

If I have only one service Class on my sever, how can I expose multiple wsdls?

Also, what is the best way of maintaining backward compatibility?

public Data getSumAndMultData(int[] input){
    Data result = new Data();
    int sum = 0;
    int mult = 1;

    for(int i = 0; i < input.length; i++){
        sum += input[i];
        mult *= input[i];
    }
    result.setMult(mult);
    result.setSum(sum);
    return result;
}
class Data{
    int sum;
    int mult;
    public int getSum() {
        return sum;
    }
    public void setSum(int sum) {
        this.sum = sum;
    }

    public int getMult() {
        return mult;
    }
    public void setMult(int mult) {
        this.mult = mult;
    }
}

As

Case #2 really just means to add new web service with its own WSDL. You would probably start with the old WSDL, make whatever changes you needed, and then publish it under a different service name so that it's accessed through a different URL.

Using Axis2, you can package more than one service into the same AAR. Within services.xml, you will define a <servicegroup> with a <service> sections each service. All of the services will use the same classloader and have access to the same set of static variables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM