コード例 #1
0
  private void _initServicoControllerPortTypeProxy() {
    try {
      servicoControllerPortType =
          (new br.gov.saudecaruaru.bpai.business.service.ServicoControllerServiceLocator())
              .getServicoControllerPort();
      if (servicoControllerPortType != null) {
        if (_endpoint != null) {
          javax.xml.rpc.Stub stub = (javax.xml.rpc.Stub) servicoControllerPortType;
          stub._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
        } else {
          _endpoint =
              (String)
                  ((javax.xml.rpc.Stub) servicoControllerPortType)
                      ._getProperty("javax.xml.rpc.service.endpoint.address");
        }

        // seta a autenticação
        javax.xml.rpc.Stub stub = (javax.xml.rpc.Stub) servicoControllerPortType;
        stub._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY, "1234");
        stub._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY, "CESAR");
      }

    } catch (javax.xml.rpc.ServiceException serviceException) {
    }
  }
コード例 #2
0
  public void callFedTaxService(boolean intendedResult) {
    double income = 97000.00;
    double deductions = 7000.00;
    try {

      FedTaxIF taxCalIFPort = taxCalService.getFedTaxIFPort();
      ((Stub) taxCalIFPort)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, fedTaxEndpoint);

      double fedTax = taxCalIFPort.getFedTax(income, deductions);
      System.out.println("Fed tax from Ejb based TaxCalService :" + fedTax);

      if (fedTax == 18000.00 && intendedResult)
        stat.addStatus(testSuite + " FedTaxPort", stat.PASS);
      else {
        System.out.println("Call succeeded while it should have failed");
        stat.addStatus(testSuite + " FedTaxPort", stat.FAIL);
      }
    } catch (Exception ex) {
      if (intendedResult) {
        System.out.println("TaxCalEjbWebService client failed");
        stat.addStatus(testSuite + " FedTaxPort", stat.FAIL);
        ex.printStackTrace();
      } else {
        System.out.println("Expected Exception caught :");
        System.out.println(ex.getMessage());
        stat.addStatus(testSuite + "FedTaxPort", stat.PASS);
      }
    }
  }
コード例 #3
0
ファイル: JAXRPCTest.java プロジェクト: veithen/ddom
 @Test
 public void testWithoutHandlers() throws Exception {
   Echo echo =
       ((EchoService) ServiceFactory.newInstance().loadService(EchoService.class)).getEchoPort();
   ((Stub) echo)
       ._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxrpc/echo");
   assertEquals("Hi!", echo.echo("Hi!"));
 }
コード例 #4
0
ファイル: JAXRPCTest.java プロジェクト: veithen/ddom
 @Test
 public void testWithHandlers() throws Exception {
   PerfDataCollector.clearPerfData();
   Calculator calculator =
       ((CalculatorService) ServiceFactory.newInstance().loadService(CalculatorService.class))
           .getCalculatorPort();
   ((Stub) calculator)
       ._setProperty(
           Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxrpc/calculator");
   assertEquals(5, calculator.add(2, 3));
   assertNotNull(PerfDataCollector.getLastPerfData());
 }
コード例 #5
0
  protected void sendNotification(
      ServerRequestContext context,
      NotifyActionType notifyAction,
      NotificationType notification,
      AuditableEventType ae)
      throws RegistryException {
    System.err.println("Sending notification to web service");

    try {
      // Get the ServiceBinding id that represents the endPoint
      String endPoint = notifyAction.getEndPoint();

      // Now get the ServiceBinding and its acceessURI
      ServiceBindingType serviceBinding =
          (ServiceBindingType)
              PersistenceManagerFactory.getInstance()
                  .getPersistenceManager()
                  .getRegistryObject(context, endPoint, "ServiceBinding");

      String accessURI = serviceBinding.getAccessURI();

      NotificationListenerPortType_Stub stub =
          (NotificationListenerPortType_Stub)
              (new NotificationListenerSOAPService_Impl().getNotificationListenerPort());
      ((Stub) stub)._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, accessURI);

      javax.xml.bind.Marshaller marshaller =
          BindingUtility.getInstance().getJAXBContext().createMarshaller();
      marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      marshaller.marshal(notification, System.err);

      SOAPElement soapElem =
          BindingUtility.getInstance().getSOAPElementFromBindingObject(notification);

      String notificationOption = notifyAction.getNotificationOption();

      if (notificationOption.equals(BindingUtility.CANONICAL_NOTIFICATION_OPTION_TYPE_ID_Objects)) {
        stub.onObjectsNotification(soapElem);
      } else if (notificationOption.equals(
          BindingUtility.CANONICAL_NOTIFICATION_OPTION_TYPE_ID_ObjectRefs)) {
        stub.onObjectRefsNotification(soapElem);
      }

    } catch (Exception e) {
      e.printStackTrace();
      throw new RegistryException(e);
    }
  }
コード例 #6
0
ファイル: JAXRPCTest.java プロジェクト: veithen/ddom
 // TODO: also add a test that receives an attachment from the service
 @Test
 public void testSwA() throws Exception {
   Attachments attachments =
       ((AttachmentsService) ServiceFactory.newInstance().loadService(AttachmentsService.class))
           .getAttachmentsPort();
   ((Stub) attachments)
       ._setProperty(
           Stub.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/jaxrpc/attachments");
   assertEquals(
       "OK",
       attachments.addAttachment(
           "12345",
           new DataHandler(
               new ByteArrayDataSource(
                   "This is a test".getBytes("UTF-8"), "application/octet-stream"))));
 }
コード例 #7
0
  public void callStateTaxService(boolean intendedResult) {
    double income = 85000.00;
    double deductions = 5000.00;

    // String targetEndpointAddress =
    //	"http://localhost:1024/taxcalculator";

    try {

      StateTaxIF taxCalIFPort = taxCalService.getStateTaxIFPort();

      ((Stub) taxCalIFPort)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, stateTaxEndpoint);

      double stateTax = taxCalIFPort.getStateTax(income, deductions);
      System.out.println("State tax from ejb based TaxCalService :" + stateTax);

      if (stateTax == 24000.00 && intendedResult)
        stat.addStatus(testSuite + " StateTaxPort", stat.PASS);
      else {
        System.out.println("Call succeeded while it should have failed");
        stat.addStatus(testSuite + " StateTaxPort", stat.FAIL);
      }

    } catch (Exception ex) {
      if (intendedResult) {
        System.out.println("TaxCalEjbWebservice client failed");
        stat.addStatus(testSuite + " StateTaxPort", stat.FAIL);
        ex.printStackTrace();
      } else {
        System.out.println("Expected Exception caught :");
        System.out.println(ex.getMessage());
        ex.printStackTrace();
        stat.addStatus(testSuite + "StateTaxPort", stat.PASS);
      }
    }
  }
コード例 #8
0
ファイル: NMASUAWSOperator.java プロジェクト: dragonarmor/pwm
  private static ResponseSet readResponsesFromNovellUA(
      final PwmApplication pwmApplication, final ChaiUser theUser)
      throws PwmUnrecoverableException {
    final String novellUserAppWebServiceURL =
        pwmApplication
            .getConfig()
            .readSettingAsString(PwmSetting.EDIRECTORY_PWD_MGT_WEBSERVICE_URL);

    try {
      LOGGER.trace("establishing connection to web service at " + novellUserAppWebServiceURL);
      final PasswordManagementServiceLocator locater = new PasswordManagementServiceLocator();
      final PasswordManagement service =
          locater.getPasswordManagementPort(new URL(novellUserAppWebServiceURL));
      ((Stub) service)._setProperty(javax.xml.rpc.Stub.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
      final ProcessUserRequest userRequest = new ProcessUserRequest(theUser.getEntryDN());
      final ForgotPasswordWSBean processUserResponse = service.processUser(userRequest);
      if (processUserResponse.isTimeout() || processUserResponse.isError()) {
        throw new Exception(
            "novell web service reports "
                + (processUserResponse.isTimeout() ? "timeout" : "error")
                + ": "
                + processUserResponse.getMessage());
      }
      if (processUserResponse.getChallengeQuestions() != null) {
        return new NovellWSResponseSet(service, processUserResponse);
      }
    } catch (Throwable e) {
      final String errorMsg =
          "error retrieving novell user responses from web service: " + e.getMessage();
      final ErrorInformation errorInformation =
          new ErrorInformation(PwmError.ERROR_SERVICE_UNREACHABLE, errorMsg);
      throw new PwmUnrecoverableException(errorInformation);
    }

    return null;
  }