Querying Web services with wsadmin
Use the Jython or Jacl scripting language to query for Web services properties with wsadmin. Use the commands in the WebServicesAdmin group to list all Web services and attributes, find attributes of a specific Web service, determine the Web service endpoint, and determine the operation name of a Web service.
The wsadmin admin scripting program supports two scripting languages, Jacl and Jython. The Jacl syntax is deprecated. This page includes examples written only in Jython.
Before we can complete the procedure for the commands in the WebServicesAdmin group, launch wsadmin.
Use the following commands to query for Web services and Web service attributes. If we receive a NoItemFoundException error, the specified application, module, service, or endpoint cannot be found. Verify that all input parameters are correct.
We can optionally specify the client parameter for any command in the WebServicesAdmin command group. The client parameter indicates whether to return service providers or service clients. Specify false to request service providers and true to request service clients.
- List installed Web services
AdminTask.listWebServices()This command returns all installed Web services. The command also returns the application name, module name, service name, and service type for each Web service.
Sample output:
'[ [service {http://www.ibm.com}service1] [client false] [application application1] [module webapp1.war] [type JAX-WS] ]'- Query the configuration for all installed Web services for a specific enterprise application. Enter the following command, and specify the name of the application you want to query:
AdminTask.listWebServices('[–application myapp -client false]')This command returns all installed Web services for the myapp that you specify. The command also returns the application name, module name, service name, and service type for each Web service.
Sample output:
'[ [service {http://www.ibm.com}service1] [client false] [application application1] [module webapp1.war] [type JAX-WS] ]'- Query the configuration for the Web service name and type for a enterprise application. Enter the following command, and specify the application name, module name, and Web service name. The client parameter is optional.
AdminTask.getWebService('[–application myapp -module module_name -service webservice_name -client false]')The command returns the Web service name and Web service type.
Sample output:
'[ [service {http://www.ibm.com}service1] [client false] [type JAX-WS] ]'- Query the configuration for the Web service endpoints for a enterprise application. The logical endpoint name is the port name in the WSDL document. Enter the following command, and specify the application name, module name, and Web service name. The client parameter is optional.
AdminTask.listWebServiceEndpoints('[–application myapp -module module_name -service webservice_name -client false]')This command returns the port on which the Web service is installed. Sample output:'[logicalEndpoint QuotePort01]'- Query the configuration for the Web service operation names for a enterprise application. Enter the following command, and specify the application name, module name, Web service name, and endpoint name. The logical endpoint name is the port name in the Web Services Description Language (WSDL) document. The client parameter is optional.
AdminTask.listWebServiceOperations('[–application myapp -module module_name -service webservice_name -logicalEndpoint endpoint_name -client false]')This command returns all Web service operations. Sample output:
'[operation ivt_app_op1] [operation ivt_app_op2]'- Query the configuration for the service providers, endpoints, and operations from each deployed asset. The listServices command provides generic query functions. Use the following command to display information about service providers, endpoints, and operations for enterprise apps and Web Services Notification (WSN) clients. Each parameter is optional. If we do not specify the queryProps parameter, the command returns each service provider in the configuration. If we do not specify the expandResources parameter, the command does not return the logical endpoints or operations for each service.
The following command example returns each service provider and the corresponding endpoints for the myApplication application:
AdminTask.listServices('-queryProps "[[CompositionUnit=myApplication][client=false]" -expandResources endpoint']
The following command example returns each JAX-WS service provider and the corresponding endpoints and operations within a cell:
AdminTask.listServices('[-queryProps "[[serviceType JAX-WS][client false]]"]')This command returns the service providers that match the search query. Sample output:
'[ [service {http://com/ibm/was/wssample/sei/echo/}EchoService] [assetType [J2EE Application]] [client false] [application WSSampleServicesSei] [module SampleServicesSei.war] [serviceType JAX-WS] ][ [service {http://com/ibm/was/wssample/sei/echo/}EchoService12] [assetType [J2EE Application]] [client false] [application WSSampleServicesSei] [module SampleServicesSei.war] [serviceType JAX-WS] ]
[service {http://com/ibm/was/wssample/sei/ping/}PingService] [assetType [J2EE Application]] [client false] [application WSSampleServicesSei] [module SampleServicesSei.war] [serviceType JAX-WS] ]
[ [service {http://com/ibm/was/wssample/sei/ping/}PingService12] [assetType [J2EE Application]] [client false] [application WSSampleServicesSei] [module SampleServicesSei.war] [serviceType JAX-WS]]'
The following command example returns each WSN service client and the corresponding endpoints and operations within a cell:
AdminTask.listServices('[-queryProps "[[serviceType [JAX-WS (WSN)]][clie nt true]]" -expandResource logicalEndpoint]')This command returns the service providers that match the search query. Sample output:
'[ [service {http://www.ibm.com/websphere/wsn/out/remote-publisher}OutboundRemotePublisherService] [assetType [WSN Service]] [client true] [bus bus1] [WSNService wsn1] [serviceType [JAX-WS (WSN)]] ][ [assetType [WSN Service]] [service {http://www.ibm.com/websphere/wsn/out/remote-publisher}OutboundRemotePublisherService] [bus bus1] [client true] [WSNService wsn1] [serviceType [JAX-WS (WSN)]] [logicalEndpoint OutboundRemotePublisherPort] ]
[ [service {http://www.ibm.com/websphere/wsn/out/notification}OutboundNotificationService] [assetType [WSN Service]] [client true] [bus bus1] [WSNService wsn1] [serviceType [JAX-WS (WSN)]] ]
[ [assetType [WSN Service]] [service {http://www.ibm.com/websphere/wsn/out/notification}OutboundNotificationService] [bus bus1] [client true] [WSNService wsn1] [serviceType [JAX-WS (WSN)]] [logicalEndpoint OutboundNotificationPort] ]'
Related tasks
Start wsadmin
Set application and system policy sets for Web services using scripting
Use scripting (wsadmin)