public void testSoap12TestRpcPortWSDL() throws Exception {
   javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
   java.net.URL url =
       new java.net.URL(
           new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator()
                   .getSoap12TestRpcPortAddress()
               + "?WSDL");
   javax.xml.rpc.Service service =
       serviceFactory.createService(
           url, new test.wsdl.soap12.assertion.WhiteMesaSoap12TestSvcLocator().getServiceName());
   assertTrue(service != null);
 }
  public static void main(String[] args) throws Exception {
    QName qname =
        new QName("http://bapp.templateA.examples.j2ee.wittydev.org/", "ServerInfoRPCService");
    URL url = new URL("http://127.0.0.1:8080/TEMPLATE_WAPP/ServerInfoRPC?wsdl");
    ServiceFactory factory = ServiceFactory.newInstance();
    Service service = factory.createService(url, qname);
    ServerInfoRPCWebService siws =
        (ServerInfoRPCWebService) service.getPort(ServerInfoRPCWebService.class);

    /**
     * * ServerInfoRPCService s=new ServerInfoRPCService_Impl();
     * System.out.println(s.getServerInfoWebServicePort());
     * System.out.println(s.getServerInfoWebServicePort().getServerTime()); *
     */
    System.out.println(siws);
  }
Ejemplo n.º 3
0
 @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!"));
 }
Ejemplo n.º 4
0
 @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());
 }
Ejemplo n.º 5
0
 // 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"))));
 }
  /**
   * Main Program
   *
   * @param args
   */
  public static void main(String[] args) throws Exception {
    String sessionID = null;

    try {
      // Create a URL end point for the client
      URL wsdlUrl = null;
      if (END_POINT_URL.isEmpty()) {
        wsdlUrl = new URL(new SugarsoapLocator().getsugarsoapPortAddress() + "?wsdl");
      } else {
        wsdlUrl = new URL(END_POINT_URL);
      }

      System.out.println("URL endpoint created successfully!");

      // Create Service for test configuration
      ServiceFactory serviceFactory = ServiceFactory.newInstance();
      Service service =
          serviceFactory.createService(wsdlUrl, new SugarsoapLocator().getServiceName());

      System.out.println("Service created successfully");
      System.out.println("Service Name:" + service.getServiceName().toString());
      System.out.println("Service WSDL:" + service.getWSDLDocumentLocation().toString());

      // Trying to create a stub
      SugarsoapBindingStub binding = new SugarsoapBindingStub(wsdlUrl, service);
      binding.setTimeout(TIMEOUT);
      System.out.println("Stub created successfully!");

      /**
       * Try to login on SugarCRM
       *
       * <p>1) Prepare a MD5 hash password 2) Prepare a User Auth object 3) Execute login
       */

      // 1. Prepare a MD5 hash password
      MessageDigest messageDiget = MessageDigest.getInstance("MD5");
      messageDiget.update(USER_PASSWORD.getBytes());

      // 2. Prepare a User Auth object
      User_auth userAuthInfo = new User_auth();
      userAuthInfo.setUser_name(USER_NAME);
      userAuthInfo.setPassword((new BigInteger(1, messageDiget.digest())).toString(16));

      try {
        // 3. Execute login
        Entry_value loginResult = binding.login(userAuthInfo, APPLICATION_NAME, null);
        System.out.println("Login Successfully for " + USER_NAME);
        System.out.println("Your session Id: " + loginResult.getId());
        sessionID = loginResult.getId();
      } catch (RemoteException ex) {
        System.out.println("Login failed. Message: " + ex.getMessage());
        ex.printStackTrace();
      }
      // binding.
      // binding.get_available_modules(session);
      // retreiveEntriesByModule(sessionID, binding, "Accounts",new
      // String[]{"name","description"},0,10);
      retreiveEntriesByModule(
          sessionID,
          binding,
          "Leads",
          new String[] {
            "name", "description", "account_name", "campaign_name",
            "salutation", "first_name", "last_name", "full_name",
            "title", "department", "email1", "email2"
          },
          0,
          10);
      retreiveEntriesByModule(
          sessionID,
          binding,
          "Campaigns",
          new String[] {
            "name", "description", "assigned_user_name", "status", "campaign_type", "expected_cost"
          },
          0,
          10);
      // retreiveModuleFields(sessionID, binding);
      // retreiveModules(sessionID, binding);
      // createAndRetreiveContact(sessionID, binding);

      /** Logout */
      try {
        binding.logout(sessionID);
        System.out.println("Logout Successfully for " + USER_NAME);
        sessionID = null;
      } catch (RemoteException ex) {
        System.out.println("Login failed. Message: " + ex.getMessage());
        ex.printStackTrace();
      }

    } catch (MalformedURLException ex) {
      System.out.println("URL endpoing creation failed. Message: " + ex.getMessage());
      ex.printStackTrace();
    } catch (ServiceException ex) {
      System.out.println("Service creation failed. Message: " + ex.getMessage());
      ex.printStackTrace();
    } catch (AxisFault ex) {
      System.out.println("AxisFault. Message: " + ex.getMessage());
      ex.printStackTrace();
    }
  }