コード例 #1
0
  protected static TaxSvcSoap getTaxSvc()
      throws ServiceException, SOAPException, MalformedURLException, IOException {
    TaxSvc taxSvc;
    TaxSvcSoap port;

    Properties properties = new Properties();
    File file = new File("security/avatax4j.properties");
    try {
      properties.load(new FileInputStream(file));
    } catch (IOException e) {
      System.out.println("Unable to load avatax4j.properties");
      throw e;
    }

    String url = properties.getProperty("avatax4j.url");
    Assert.assertFalse(
        "avatax4j.url property is not configured in avatax4j.properties",
        url == null || url.length() == 0);

    String account = properties.getProperty("avatax4j.account");
    Assert.assertFalse(
        "avatax4j.account property is not configured in avatax4j.properties",
        account == null || account.length() == 0);

    String license = properties.getProperty("avatax4j.license");
    Assert.assertFalse(
        "avatax4j.license property is not configured in avatax4j.properties",
        license == null || license.length() == 0);

    taxSvc = new TaxSvcLocator();

    port = taxSvc.getTaxSvcSoap(new URL(url));

    // Set the profile
    Profile profile = new Profile();
    profile.setClient("TaxSvcTest,4.0.0.0");
    port.setProfile(profile);

    // Set security
    Security security = new Security();
    security.setAccount(account);
    security.setLicense(license);
    port.setSecurity(security);

    return port;
  }