Search in sources :

Example 1 with Authentication

use of com.AddressDoctor.validator2.addInteractive.Interactive.Authentication in project tdi-studio-se by Talend.

the class AddressDoctorClient method formatAndValidate.

/**
     * This is new API, let user to define a structured data "Address" to transmit to the server
     * 
     * @see: bug:6025
     * @param args
     * @throws Exception
     */
public static AddInteractiveResponse formatAndValidate(Long userId, String password, Address address, CountryOfOriginType originCountry, CountryType countryType, LineSeparatorType lineSeparator, CapitalizationType capitalize) throws Exception {
    try {
        // Parameter to set in component
        // String webServiceURI (should always be
        // http://validator2.addressdoctor.com/addInteractive/Interactive.asmx) -> no parameter for this
        InteractiveSoap interactiveSoap = (new com.AddressDoctor.validator2.addInteractive.Interactive.InteractiveLocator()).getInteractiveSoap();
        AddInteractiveRequest addInteractiveRequest = new AddInteractiveRequest();
        Parameters parameters = new Parameters();
        addInteractiveRequest.setAddress(address);
        // Advanced Parameter Settings
        parameters.setCountryOfOrigin(originCountry);
        parameters.setCountryType(countryType);
        parameters.setLineSeparator(lineSeparator);
        parameters.setCapitalization(capitalize);
        parameters.setPreferredLanguage(PreferredLanguageType.PFL_PRIMARY);
        addInteractiveRequest.setParameters(parameters);
        // web service call
        addInteractiveRequest.setAuthentication(new Authentication(userId, 0, password));
        AddInteractiveResponse resp = interactiveSoap.validate(addInteractiveRequest);
        return resp;
    } catch (ServiceException e) {
        throw e;
    } catch (RemoteException e) {
        throw e;
    }
}
Also used : InteractiveSoap(com.AddressDoctor.validator2.addInteractive.Interactive.InteractiveSoap) Parameters(com.AddressDoctor.validator2.addInteractive.Interactive.Parameters) ServiceException(javax.xml.rpc.ServiceException) Authentication(com.AddressDoctor.validator2.addInteractive.Interactive.Authentication) AddInteractiveResponse(com.AddressDoctor.validator2.addInteractive.Interactive.AddInteractiveResponse) AddInteractiveRequest(com.AddressDoctor.validator2.addInteractive.Interactive.AddInteractiveRequest) RemoteException(java.rmi.RemoteException)

Example 2 with Authentication

use of com.AddressDoctor.validator2.addInteractive.Interactive.Authentication in project tdi-studio-se by Talend.

the class AddressDoctorClient method formatAndValidate.

/**
     * This is old API, via "DeliveryAddressLines" to transmit the input data to the server
     * 
     * @see: bug:6025
     * @param args
     * @throws Exception
     */
public static Result[] formatAndValidate(Long userId, String password, String addressLines, CountryOfOriginType originCountry, CountryType countryType, LineSeparatorType lineSeparator, CapitalizationType capitalize) throws Exception {
    try {
        // Parameter to set in component
        // String webServiceURI (should always be
        // http://validator2.addressdoctor.com/addInteractive/Interactive.asmx) -> no parameter for this
        InteractiveSoap interactiveSoap = (new com.AddressDoctor.validator2.addInteractive.Interactive.InteractiveLocator()).getInteractiveSoap();
        AddInteractiveRequest addInteractiveRequest = new AddInteractiveRequest();
        Parameters parameters = new Parameters();
        Address address = new Address();
        // set address with input row fixed schema
        address.setDeliveryAddressLines(addressLines);
        addInteractiveRequest.setAddress(address);
        // Advanced Parameter Settings
        parameters.setCountryOfOrigin(originCountry);
        parameters.setCountryType(countryType);
        parameters.setLineSeparator(lineSeparator);
        parameters.setCapitalization(capitalize);
        parameters.setPreferredLanguage(PreferredLanguageType.PFL_PRIMARY);
        addInteractiveRequest.setParameters(parameters);
        // web service call
        addInteractiveRequest.setAuthentication(new Authentication(userId, 0, password));
        AddInteractiveResponse resp = interactiveSoap.validate(addInteractiveRequest);
        Result[] results = resp.getResults();
        if (resp.getResultCount() > 0) {
            return results;
        } else {
            throw new Exception(resp.getErrorCode() + ":" + resp.getErrorMessage() + ":" + resp.getValidationStatus());
        }
    } catch (ServiceException e) {
        throw e;
    } catch (RemoteException e) {
        throw e;
    }
}
Also used : Parameters(com.AddressDoctor.validator2.addInteractive.Interactive.Parameters) Address(com.AddressDoctor.validator2.addInteractive.Interactive.Address) AddInteractiveRequest(com.AddressDoctor.validator2.addInteractive.Interactive.AddInteractiveRequest) ServiceException(javax.xml.rpc.ServiceException) RemoteException(java.rmi.RemoteException) Result(com.AddressDoctor.validator2.addInteractive.Interactive.Result) InteractiveSoap(com.AddressDoctor.validator2.addInteractive.Interactive.InteractiveSoap) ServiceException(javax.xml.rpc.ServiceException) Authentication(com.AddressDoctor.validator2.addInteractive.Interactive.Authentication) AddInteractiveResponse(com.AddressDoctor.validator2.addInteractive.Interactive.AddInteractiveResponse) RemoteException(java.rmi.RemoteException)

Aggregations

AddInteractiveRequest (com.AddressDoctor.validator2.addInteractive.Interactive.AddInteractiveRequest)2 AddInteractiveResponse (com.AddressDoctor.validator2.addInteractive.Interactive.AddInteractiveResponse)2 Authentication (com.AddressDoctor.validator2.addInteractive.Interactive.Authentication)2 InteractiveSoap (com.AddressDoctor.validator2.addInteractive.Interactive.InteractiveSoap)2 Parameters (com.AddressDoctor.validator2.addInteractive.Interactive.Parameters)2 RemoteException (java.rmi.RemoteException)2 ServiceException (javax.xml.rpc.ServiceException)2 Address (com.AddressDoctor.validator2.addInteractive.Interactive.Address)1 Result (com.AddressDoctor.validator2.addInteractive.Interactive.Result)1