package ExemplosAttributionMecanismService; import javax.xml.ws.BindingProvider; import com.datasul.technology.webdesk.foundation.ws.AttributionMecanismDto; import com.datasul.technology.webdesk.foundation.ws.AttributionMecanismDtoArray; import com.datasul.technology.webdesk.foundation.ws.AttributionMecanismService; import com.datasul.technology.webdesk.foundation.ws.AttributionMecanismServiceService; /** * Class that uses all the methods of AttributionMecanismService. * With this class, you can search the register assignment mechanisms in the ECM. * On the setParameters method, you can set some of the variables that are most used as parameters in the methods of this class. * On the changeMethod method, you can choose which method will be executed. */ public class AttributionMecanismServiceClient { // Variables. String loginColaborador, senhaColaborador; int codigoEmpresa; // Instantiates AttributionMecanismServiceService. AttributionMecanismServiceService attributionMecanismServiceService = new AttributionMecanismServiceService(); AttributionMecanismService service = attributionMecanismServiceService.getAttributionMecanismServicePort(); // Starts execution of the class. public static void main (String args[]) { System.out.println("\nClasse AttributionMecanismService"); // Instantiates GlobalParamServiceClient class. AttributionMecanismServiceClient gpsc = new AttributionMecanismServiceClient(); // Configures access to WebServices. BindingProvider bp = (BindingProvider) gpsc.service; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://10.80.74.87:8080/webdesk/AttributionMecanismService"); try { // Calls method that configures the values of the variables. gpsc.setParameters(); // Calls method responsible for performing the methods of the class. gpsc.changeMethod(); } catch (Exception e) { e.printStackTrace(); } } /** * Configures parameters. * In this method you can set some of the variables that are most used as parameters in the methods of this class. */ public void setParameters() throws Exception { this.loginColaborador = "adm"; this.senhaColaborador = "adm"; this.codigoEmpresa = 1; } /** * Chooses method. * In this method, you can choose which method of the class to be executed. */ public void changeMethod() throws Exception { // Calls getAttributionMecanism method. this.getAttributionMecanism(); } /** * Returns information from the assignment mechanisms. * * Method: getAttributionMecanism. * * Parameters: * - User Login; * - User password; * - Company code; */ public void getAttributionMecanism() throws Exception { System.out.println("\nMétodo getAttributionMecanism\n"); AttributionMecanismDtoArray mecanismDtoArray = service.getAttributionMecanism(this.loginColaborador, this.senhaColaborador, this.codigoEmpresa); if(!mecanismDtoArray.getItem().isEmpty()){ for(AttributionMecanismDto mecanismDto : mecanismDtoArray.getItem()){ System.out.println("Código: " + mecanismDto.getAttributionMecanismId()); System.out.println("Descrição: " + mecanismDto.getAttributionMecanismDescription()); System.out.println("..."); } }else{ System.out.println("Não no assignment mechanism found!"); } } }