Monday 30 July 2018

Oracle ADF Soap WebService

Oracle ADF Soap WebService

public class Country {
    public void setCountryId(String CountryId) {
        this.CountryId = CountryId;
    }

    public String getCountryId() {
        return CountryId;
    }

    public void setCountryName(String CountryName) {
        this.CountryName = CountryName;
    }

    public String getCountryName() {
        return CountryName;
    }
    String CountryId;
    String CountryName;
 
    public Country(String Id, String Name) {
        super();
        this.CountryId=Id;
        this.CountryName=Name;
    }
    public Country() {
        super();
    }
}


package client;

import java.util.ArrayList;
import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebService;

import javax.xml.ws.BindingType;
import javax.xml.ws.soap.SOAPBinding;

@WebService(serviceName = "CountriesService1", portName = "CountriesPort1")
@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
public class Countries {
    List<Country> countries=new ArrayList <Country>();
 
    public Countries() {
        super();
    }

    @WebMethod(exclude = true)
    public void setCountries(List<Country> countries) {
        this.countries = countries;
    }

    public List<Country> getCountries() {
        if(countries.size()==0) {
            countries.add(new Country("IT","ITALY"));
            countries.add(new Country("IN","INDIA"));
            countries.add(new Country("US","UNITED STATES"));
        }
        return countries;
    }
    public boolean addCountry(Country country) {
        return countries.add(country);
    }
}