| Sun Java System Application Server |
This sample application provides an example of a simple web service based on the Web Services for J2EE. It includes a web service named managementws and a stand-alone Java client named Client.
The ManagementWSIF interface is the service endpoint that defines the methods of the web service.
The ManagementWS_Impl class implements this interface. Before
the first request, Application Server creates and manages a service instance,
the ManagementWSPort Port component.
The standalone client uses JNDI lookup to access the ManagementWS Service object. It then
gets access to ManagementWSPort and invokes the service's methods.
This web service application requires modification of the server's default security policy. Before you invoke the web service, follow these steps:
domain_root_dir/domain_name/config/server.policy
// permissions for managementws classes
grant {
permission javax.management.MBeanPermission "*", "*";
permission java.lang.RuntimePermission "*";
};
You must also enter the URL of the web service in the WSDL file.
Edit app_dir/managementws-share/web/WEB-INF/wsdl/ManagementWS.wsdl.
Look for the following line:
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
Change "REPLACE_WITH_ACTUAL_URL" to http://hostname:instance-port/managementws.
The general instructions for building, deploying, and running sample applications are provided in Building, Deploying, and Running Sample Applications. In reading this document, use the following application-specific variables for this application:
install_dir is the directory where Application Server
is installed.
app_dir is the application base directory: install_dir/samples/webservices/jaxrpc/apps/managementws.
managementws.ear.
Follow this general procedure:
build.xml, is in the app_dir
directory, specifically, install_dir/samples/webservices/jaxrpc/apps/managementws.
install_dir/samples/webservices/jaxrpc/apps/managementws/managementws.ear.
install_dir/samples/webservices/jaxrpc/apps/managementws
asant run.
The program displays the following:
Buildfile: build.xml
run:
package-client:
[echo] Building the client JAR file....
[delete] Deleting: app_dir\managementws-standalone-client\build\assemble\
client\managementwsClient.jar
[jar] Building jar: app_dir\managementws-standalone-client\build\assemble\
client\managementwsClient.jar
run-client:
[echo] Running the jaxrpcmejb.Client program:
[java] Endpoint address = http://localhost:8080/service/ManagementService
[java] ListenerURI = http://ottid:4371
[java] Default Domain = DefaultDomain
[java] Number of MBeans = 305
[java] queryNames *:* found 305 names
[java] test isRegistered = true
[java] queryNames JMImplementation:type=MBeanServerDelegate found 1 names
[java] [ 0 ]
[java] ObjectName: JMImplementation:type=MBeanServerDelegate
[java] Description: Represents the MBean server from the management point of view.
[java] *** Attributes ***
[java] name: MBeanServerId value: ottid_1086721589573
[java] name: SpecificationName value: Java Management Extensions
[java] name: SpecificationVersion value: 1.2 Maintenance Release
[java] name: SpecificationVendor value: Sun Microsystems
[java] name: ImplementationName value: JMX
[java] name: ImplementationVersion value: 1.2.2_r34
[java] name: ImplementationVendor value: Sun Microsystems
[java] *********************
[java] *** Constructors ***
[java] *********************
[java] *** Notifications ***
[java] Name: javax.management.MBeanServerNotification
[java] Description: Notifications sent by the MBeanServerDelegate MBean
[java] JMX.mbean.unregistered
[java] JMX.mbean.registered
[java] *********************
...
install_dir/samples/quickstart.
asant deploy.
You will then see deployment events displayed in the first shell window (where you ran the client).
You will see output similar to this:
[java] NOTIFICATION RECIEVED:
[java] message =
[java] sequence = 332
[java] source = JMImplementation:type=MBeanServerDelegate
[java] timestamp = 1086725008188
[java] type = JMX.mbean.unregistered
[java] user data = null
[java] handback = MEJB
[java] MBean Name = com.sun.appserv:type=RequestProcessor,worker=http1618,name=HttpRequest1
Ctrl-C in the first shell window (where you ran the client).
When you run the client, if you see the error Connection refused, make certain that the
soap:address setting in
app_dir/managementws-share/web/WEB-INF/wsdl/ManagementWS.wsdl
is set to http://hostname:instance-port/managmenetws.
If you need to modify the file, execute asant core before running the sample again.
Copyright © 2006 Sun Microsystems, Inc. All rights reserved.