spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / java / webservices / chap3 / 2 To page 1To page 2current pageTo page 4To page 5
[previous] [next]

Professional Java Web Services

Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


Registering the Service

After creating a deployment descriptor for the service, it has to be registered with the SOAP run-time environment. This is done through the use of the ServiceManagerClient class. The "Hello World" service can be registered by entering the following command:

> java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter deploy HelloWorldDD.xml

The first parameter specifies the URL of the Apache SOAP RPC router, which is responsible for routing client requests to the requested service. The second parameter specifies the operation that the client should do. The deploy operation consists of registering the service using the deployment information located in a file specified by the third parameter. In this case, the file is called HelloWorldDD.xml and it contains the deployment descriptor for the "Hello World" Service.

To see if the service was actually registered we ask the Apache SOAP runtime to provide us with a list registered services. This can be done using the following command line:

> java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list

The first parameter is the same, but the operation is list instead of deploy. This output will be shown when running the above commands:

C:\javawebservices\Ch03\helloworld>java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter deploy HelloWorldDD.xml

C:\javawebservices\Ch03\hellowworld>java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list
Deployed Services:
           urn:HelloWorldService

C:\javawebservices\Ch03\helloworld>

The ServiceManagerClient can also be used to un-register a service. The "Hello World" service can be un-registered by typing this:

> java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter undeploy "urn:HelloWorldService"

Notice that the operation is undeploy instead of deploy and that the third parameter is the name of the service defined by the id attribute of the service element within the deployment descriptor.

It's also worth mentioning that the ServiceManagerClient can be used for querying the attributes of a service. The following command can be used to query the attributes of the "Hello World" service:

> java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter query "urn:HelloWorldService"

The parameters are the same as the undeploy version of the command, except that the undeploy operation is replaced by query. The following output will appear from running the above command:

C:\javawebservices\Ch03helloworld>java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter query "urn:HelloWorldService"
<isd:service xmlns:isd=http://xml.apache.org/xml-soap/deployment" id="urn:WorldService" checkMustUnderstands="false">
  <isd:provider type="java" scope="Application" methods="getMessage">
    <isd:java class="com.wrox.helloworld.service.HelloWorld" static="false">
  </isd:provider>
  <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
</isd:service>

C:\javawebservices\Ch03helloworld>

Notice that the output from this command is just the contents of the deployment descriptor that we provided when we initially deployed the service.

It's worth noting, that by default, anyone can use the ServiceManagerClient to deploy a service, undeploy a service, list registered services, and query the attributes of a service. However, it does contain support for HTTP Basic Authentication. In order to enable security you would have to modify the web.xml file that's located in <TOMCAT_HOME>\webapps\soap\WEB-INF to secure the http://localhost:8080/soap/servlet/rpcrouter endpoint and include the -auth switch when executing the ServiceManagerClient. For example, if security were enabled the following command line would have to be specified in order to deploy the "Hello World" service:

> java org.apache.soap.server.ServiceManagerClient –auth deployer:password http://localhost:8080/soap/servlet/rpcrouter deploy HelloWorldDD.xml

The value that follows the -auth switch has a format of username:password. The value should consist of a valid username and password that has permissions to the http://localhost:8080/soap/servlet/rpcrouter endpoint. The undeploy, list, and query operations all work in a similar fashion.


home / programming / java / webservices / chap3 / 2 To page 1To page 2current pageTo page 4To page 5
[previous] [next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

Created: May 23, 2002
Revised: May 23, 2002

URL: http://webreference.com/programming/java/webservices/chap3/2/3.html