Beispiele für Java Apache Axis2-Webservices-Clients – aktualisieren

  • Freigeben Version: Xanadu
  • Aktualisiert 1. August 2024
  • 1 Minute Lesedauer
  • Ein Beispiel für ein Axis-Client-Programm, das die Funktion „getKeys“ aufruft, um alle Incidents abzufragen, bei denen die Kategorie „Hardware“ lautet.

    getKeys

    Eine Liste der sys_id wird als Ergebnis zurückgegeben:
    package com.service_now.www ;
     
     public class DemoClient  {
     
      public static void main ( String args [ ] ) { try {
       ServiceNowStub proxy  = new ServiceNowStub ( ) ;
       ServiceNowStub. GetKeys getInc  = new ServiceNowStub. GetKeys ( ) ;
       ServiceNowStub. GetKeysResponse resp  = new ServiceNowStub. GetKeysResponse ( ) ;
     
       getInc. setActive ( true ) ;
       getInc. setCategory ( "hardware" ) ;
     
       proxy._getServiceClient ( ). getOptions ( ). setProperty (org. apache. axis2. transport. http. HTTPConstants. CHUNKED,  Boolean. FALSE ) ;
     
       resp  = proxy. getKeys (getInc ) ;
     
        String [ ] keys  = resp. getSys_id ( ) ;
     
        System. out. println ( "Key: " + keys [ 0 ] ) ; } catch ( Exception e ) { System. out. println (e. toString ( ) ) ; }
     
      } }

    getRecords

    package com.service_now.www ;
     
     import com.service_now.www.ServiceNowStub.GetRecordsResult_type0 ;
     
     public class GetRecords  {
     
     /**
    * @param args
    */ public static void main ( String [ ] args ) { try {
      ServiceNowStub proxy  = new ServiceNowStub ( ) ;
      ServiceNowStub. GetRecords incidents  = new ServiceNowStub. GetRecords ( ) ;
      ServiceNowStub. GetRecordsResponse result  = new ServiceNowStub. GetRecordsResponse ( ) ;
     
      incidents. setActive ( true ) ;
      incidents. setCategory ( "hardware" ) ;
      incidents. setSys_created_on ( "> 2009-06-08 10:30:00" ) ;
     
      proxy._getServiceClient ( ). getOptions ( ). setProperty (org. apache. axis2. transport. http. HTTPConstants. CHUNKED,  Boolean. FALSE ) ;
     
      result  = proxy. getRecords (incidents ) ;
     
      GetRecordsResult_type0 [ ] keys  = result. getGetRecordsResult ( ) ;
     
       for ( int key  = 0 ; key  < keys. length ; key ++ ) { System. out. println ( "Key: " + keys [ 0 ]. getSys_id ( ) ) ; } } catch ( Exception e ) { System. out. println (e. toString ( ) ) ; }
     
     
     }
     
     }