Querying web services
We can use the Jython or Jacl scripting language to query for web services properties with wsadmin.sh. Use the commands in the WebServicesAdmin group to list all web services, service references 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 administrative scripting program supports two scripting languages, Jacl and Jython. The Jacl syntax is deprecated. Examples written only in the Jython scripting language are included.
Before we can complete the procedure for the commands in the WebServicesAdmin group, you must launch wsadmin.sh.
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 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.
- Query the configuration for all installed web services for all enterprise applications.
Enter the following command. You do not need to specify the application parameter for this command.
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 to query:
AdminTask.listWebServices('[-application application_name -client false]')
This command returns all installed web services for the application_name specified. 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 an 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 application_name -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 an 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 application_name -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 an 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 WSDL document. The client parameter is optional.
AdminTask.listWebServiceOperations('[-application application_name -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 applications 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://www.ibm.com}EchoService] [assetType [J2EE Application]] [client false] [application WSSampleServicesSei] [module SampleServicesSei.war] [serviceType JAX-WS] ] [ [service {http://www.ibm.com}EchoService12] [assetType [J2EE Application]] [client false] [application WSSampleServicesSei] [module SampleServicesSei.war] [serviceType JAX-WS] ] [service {http://www.ibm.com}PingService] [assetType [J2EE Application]] [client false] [application WSSampleServicesSei] [module SampleServicesSei.war] [serviceType JAX-WS] ] [ [service {http://www.ibm.com}PingService12] [assetType [J2EE Application]] [client false] [application WSSampleServicesSei] [module SampleServicesSei.war] [serviceType JAX-WS]]'Use the listServices command to learn about service references. We can use the serviceRef property with the queryProps parameter with the listServices command to query all service references or a specific service reference. This parameter is only applicable for service clients. If we specify an asterisk (*) as a wildcard as the name of the service reference, all of the service references for the matching service client are returned. We can also query a specific service reference by specifying the name of the service reference we want. To return detailed service reference information for endpoints and operations, specify the expandResource property.
The following command example lists all service clients and service references in a cell:
AdminTask.listServices('[-queryProps [[client true] [serviceRef *]]]')
This command returns the service references that match the search query.
In the following sample output, the EchoService and Echoservice12 service clients are listed and these clients do not have service references in the cell. However, TestService and TestService2 service clients do have service references. There is one properties object for each service reference in the service client. The component name is only available for an EJB module.
'[ [service {http://www.ibm.com}EchoService] [assetType [J2EE Application]] [client true] [application JaxWSServicesSamples] [module SampleClientSei.war] [serviceType JAX-WS] ] [ [service {http://www.ibm.com}EchoService12] [assetType [J2EE Application]] [client true] [application JaxWSServicesSamples] [module SampleClientSei.war] [serviceType JAX-WS] ] [ [service {http://www.ibm.com}TestService] [assetType [J2EE Application]] [client true] [application JaxWSServicesSamples] [module SampleClientSei.war] [serviceType JAX-WS] ] [ [serviceRef testRef] [assetType [J2EE Application]] [service {http://www.ibm.com}TestService] [client true] [application JaxWSServicesSamples] [module SampleClientSei.war] [serviceType JAX-WS] ] [ [service {http://www.ibm.com}TestService2] [assetType [J2EE Application]] [client true] [application JaxWSServicesSamples] [module SampleClientSei.war] [serviceType JAX-WS] ] [ [serviceRef testRef2] [assetType [J2EE Application]] [service {http://www.ibm.com}TestService2] [client true] [application JaxWSServicesSamples] [module SampleClientSei.war] [serviceType JAX-WS] ]The following command example lists a specific service reference by expanding endpoints and operations:
AdminTask.listServices('[-queryProps [[client true] [application JaxWSServicesSamples] [module SampleClientSei.war] [serviceRef testRef] -expandResource logicalEndpoint]')This command returns the specified service references for testRef and the serviceRef property is included in each properties object; for example:'[ [serviceRef testRef] [service {http://www.ibm.com}TestService] [assetType [J2EE Application]] [client true] [application JaxWSServicesSamples] [module SampleClientSei.war] [serviceType JAX-WS] ] [ [serviceRef testRef] [module SampleClientSei.war] [serviceType JAX-WS] [client true] [service {http://www.ibm.com}TestService] [assetType [J2EE Application]] [logicalEndpoint portA] [application JaxWSServicesSamples] ] [ [serviceRef testRef] [module SampleClientSei.war] [serviceType JAX-WS] [client true] [service {http://www.ibm.com}TestService] [assetType [J2EE Application]] [logicalEndpoint portB] [application JaxWSServicesSamples] ]'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)]][client 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] ]'
Subtopics
- WebServicesAdmin (AdminTask)
We can use the Jython or Jacl scripting languages to configure security with wsadmin.sh. Use the commands in the WebServicesAdmin group to list all web services, service references and attributes, find attributes of a specific web service, determine the web service endpoint, and determine the operation name of a Web service.
Related tasks
Start the wsadmin scripting client Configure application and system policy sets for web services Use wsadmin scripting