Guest User

WS-test-java

a guest
Mar 14th, 2011
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.74 KB | None | 0 0
  1. //SampleData.java
  2.  
  3. package wstest;
  4.  
  5. import java.util.Date;
  6. import java.util.GregorianCalendar;
  7. import java.util.Random;
  8.  
  9. /**
  10.  *
  11.  * @author victor.sakhnov
  12.  */
  13. public class SampleData {
  14.     public Date dateField;
  15.     public String stringField;
  16.     public double doubleField;
  17.     public int intField;
  18.    
  19.     public SampleData() {
  20.         this.dateField = GregorianCalendar.getInstance().getTime();
  21.         this.stringField = "Some string";
  22.         Random r = new Random();
  23.         this.doubleField = r.nextDouble();
  24.         this.intField = r.nextInt();
  25.     }
  26. }
  27. /***********************************************************************/
  28.  
  29. // NewWebService.java
  30. package wstest;
  31.  
  32. import javax.jws.WebMethod;
  33. import javax.jws.WebParam;
  34. import javax.jws.WebService;
  35.  
  36. /**
  37.  *
  38.  * @author victor.sakhnov
  39.  */
  40. @WebService()
  41. public class NewWebService {
  42.  
  43.     public NewWebService() {
  44.     }
  45.  
  46.     /**
  47.      * Web service operation
  48.      */
  49.     @WebMethod(operationName = "hello")
  50.     public String hello(@WebParam(name = "name")
  51.     String name) {
  52.         return "Hello, "+name;
  53.     }
  54.  
  55.     /**
  56.      * Web service operation
  57.      */
  58.     @WebMethod(operationName = "oneObject")
  59.     public SampleData[] oneObject() {
  60.         SampleData[] ar = new SampleData[1];
  61.         ar[0] = new SampleData();
  62.         return ar;
  63.     }
  64.  
  65.     /**
  66.      * Web service operation
  67.      */
  68.     @WebMethod(operationName = "manyObjects")
  69.     public SampleData[] manyObjects(@WebParam(name = "howMany")
  70.     int howMany) {
  71.         SampleData[] ar = new SampleData[howMany];
  72.         for(int i=0; i<howMany; i++){
  73.             ar[i] = new SampleData();
  74.         }
  75.         return ar;
  76.     }
  77. }
  78. /****************************************************************/
Advertisement
Add Comment
Please, Sign In to add comment