Extension SDK

oracle.jdeveloper.webservices
Class WebServiceModel

java.lang.Object
  extended byoracle.jdeveloper.webservices.WebServiceModel

public final class WebServiceModel
extends java.lang.Object

This class provides a public API for creating and updating web services. Only "Oracle J2EE Web Services" are supported.

Creating a web service:
The most simple use case is to create a new web service, based on an existing class. To do this, instantiate the WebServiceModel as follows:

WebServiceModel model = new WebServiceModel("mypackage1.Class1");

where mypackage1.Class1 is the fully qualified package name of the class you want to publish as a web service. If this class does not exist it will be created.

Finding an existing web service:
The model for an existing web service can be located using the functionality provided by the WebServiceManager. For example, services can be found (within a given project context) by web service class name, or by web service name. For example, to find the model for a web service based on the class mypackage1.Class1 in the currently active project:

JProject activeProject = (JProject)Ide.getActiveProject().getData(); WebServiceManager manager = WebServiceManager.getInstance(); WebServiceModel model = manager.findByClassName("mypackage1.Class1");

Method selection:
When creating a new web service based on a given class, which methods will be included in that web service? Initially, only methods eligible for publishing (see documentation) which are marked with the webmethod javadoc tag will be published.

When regenerating an existing web service all the methods which were previously selected (providing they still exist unchanged), plus those with the webmethod javadoc tag will be published.

If no methods are selected then the generator will throw an exception.

Setting properties:
All of the other properties will initially be defaulted to the values described in the accessor methods on this class. These default values may be overwritten using the accessors.

Generating the web service:
When you are ready to create the web service, call commit() on the WebServiceModel. Calling:

model.commit(false);

will result in generation occurring without any UI interaction. Alternatively, you can call:

model.commit(true);

and the web service publishing wizard will be invoked, to allow UI interaction before completion.

Getting the methods described on the generated WSDL: Once the model has been committed and then web service generated you can get the methods described on the WSDL for this web services by calling getMethods(). This will return an array of oracle.jdeveloper.webservices.util.MethodSignature objects, which describe the signatures of the methods in the WSDL document in Java.

Methods can be added to the web service implementation class and then WSDL document using addMethod(). Similarly, method signatures can be updated using updateMethod() or unpublished using unpublishMethod().

Adding and removing model change notification listeners: Users of the public web services API may want to listeners, to notify when the web service model is modified by another source. In order to do this, implement the WebServiceModelListener interface, which has the modelChanged() method. Then attach the listener to the WebServiceModel:

WebServiceModelListener listenerImpl = new ... model.addModelListener(listenerImpl);

To remove the listener, call:




Constructor Summary
WebServiceModel(Project project, java.lang.String qualifiedWebServiceClass)
          Create a WebServiceModel.
WebServiceModel(Project project, java.net.URL wsdlURL)
          Create a read-only WebServiceModel based on a given WSDL file.
 
Method Summary
 void addMethod(MethodSignature method)
          Add a method to both the WSDL file and the web service class.
 void addModelListener(WebServiceModelListener wsModelListener)
          Register a listener to events generated by this WebServiceModel.
 boolean commit(boolean showUI)
          Commit the changes to the model and generate a web service, which consists of: A web service container.
 void createImplementation(java.lang.String clazz)
          Create a web service implementation class.
 java.lang.String getAppServer()
          Get the name of the application server connection used to construct the WSDL endpoint.
 oracle.jdevimpl.webservices.ide.WebServicesContainer getContainer()
          Get the WebServicesContainer for this web service.
 java.lang.String[] getDependents()
          Get the stubs and skeletons which have a dependency on this web service.
 java.lang.String getGUID()
          Get the unqiue ID for this web service.
 MethodSignature[] getMethods()
          Get the methods currently defined on the WSDL file.
 java.lang.String getPortNo()
          Get the port number to be used in constructing the WSDL endpoint.
 java.lang.String getTargetNamespace()
          Get the targetNamespace used in WSDL generation.
 java.lang.String getTimeout()
          Get the timeout value (in seconds), only used in stateful web services.
 java.lang.String getWebServiceClass()
          Get the fully qualified name of the web service class.
 oracle.jdevimpl.webservices.wsdl.WebServiceMethod[] getWebServiceMethods()
           
 java.lang.String getWebServiceName()
          Get the web service name.
 java.net.URL getWSDLFileLocation()
          Get the location of the generated WSDL file.
 boolean isReadOnly()
          Is this WebServiceModel read only?
 boolean isStateless()
          Is the web service stateless or stateful.
 void performMethodUpdates()
          Add, unpublish and update methods.
 void refactor(java.lang.String newWebServiceClass)
           
 void remove()
          Remove this web service, deleting the container, WSDL and interface deployment descriptor, and remove the relevant web.xml entries.
 void remove(boolean notify)
          Remove this web service, deleting the container, WSDL and interface deployment descriptor, and remove the relevant web.xml entries.
 void removeModelListener(WebServiceModelListener wsModelListener)
          Remove a registered WebServiceModel listener.
 void rollback()
          Rollback any addMethod(), updateMethod() or unpublishMethod() operations since the last commit().
 void setAppServer(java.lang.String appServer)
          Set the name of the application server connection to use for constructing the WSDL endpoint.
 void setOpenFiles(boolean openFiles)
          Set whether you want the web services log window to appear, and the generated files to be opened.
 void setPortNo(java.lang.String portNo)
          Set the port number to be used in constructing the WSDL endpoint.
 void setStateless(boolean stateless)
          Set the web service to be stateless or stateful.
 void setTargetNamespace(java.lang.String targetNamespace)
          Set the targetNamespace for use in WSDL generation.
 void setTimeout(java.lang.String timeout)
          Set the timeout value (in seconds), only used in stateful web services.
 void setWebServiceName(java.lang.String webServiceName)
          Set the web service name.
 boolean signaturesEqual(MethodSignature sig1, MethodSignature sig2)
          Compare the two supplied method signatures, and check whether they are the same.
 void startEmbeddedServer()
          Start this web service in the embedded OC4J server.
 void terminateEmbeddedServer()
          If it is running, terminate the embedded OC4J server running this web service.
 void unpublishMethod(MethodSignature method)
          Unpublish the method from the WSDL file (i.e.
 void updateMethod(MethodSignature oldMethod, MethodSignature newMethod)
          Unpublish the webmethod javadoc tag from the old method on the web service class (but do not remove the method itself).
 void useAPIContext(boolean useAPIContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebServiceModel

public WebServiceModel(Project project,
                       java.lang.String qualifiedWebServiceClass)
Create a WebServiceModel. Only the fully qualified class name needs to be specified. The rest of the properties are initially defaulted, but may be set using the accessors.

Parameters:
project - The project in which to create the web service.
qualifiedWebServiceClass - The qualified name of the class to publish as a web service.

WebServiceModel

public WebServiceModel(Project project,
                       java.net.URL wsdlURL)
Create a read-only WebServiceModel based on a given WSDL file.

Method Detail

getGUID

public java.lang.String getGUID()
Get the unqiue ID for this web service.


getWebServiceClass

public java.lang.String getWebServiceClass()
Get the fully qualified name of the web service class. This can only be changed by calling refactor().


setWebServiceName

public void setWebServiceName(java.lang.String webServiceName)
                       throws java.lang.Exception
Set the web service name. The default name is the same as the class name.

Throws:
java.lang.Exception

getWebServiceName

public java.lang.String getWebServiceName()
Get the web service name.


setAppServer

public void setAppServer(java.lang.String appServer)
                  throws java.lang.Exception
Set the name of the application server connection to use for constructing the WSDL endpoint.

Throws:
java.lang.Exception

getAppServer

public java.lang.String getAppServer()
Get the name of the application server connection used to construct the WSDL endpoint.


setStateless

public void setStateless(boolean stateless)
                  throws java.lang.Exception
Set the web service to be stateless or stateful. Default is stateless.

Throws:
java.lang.Exception

isStateless

public boolean isStateless()
Is the web service stateless or stateful.


setTimeout

public void setTimeout(java.lang.String timeout)
                throws java.lang.Exception
Set the timeout value (in seconds), only used in stateful web services. Default is 60 seconds.

Throws:
java.lang.Exception

getTimeout

public java.lang.String getTimeout()
Get the timeout value (in seconds), only used in stateful web services.


setPortNo

public void setPortNo(java.lang.String portNo)
               throws java.lang.Exception
Set the port number to be used in constructing the WSDL endpoint. Default is port 8888.

Throws:
java.lang.Exception

getPortNo

public java.lang.String getPortNo()
Get the port number to be used in constructing the WSDL endpoint.


setTargetNamespace

public void setTargetNamespace(java.lang.String targetNamespace)
                        throws java.lang.Exception
Set the targetNamespace for use in WSDL generation. This is defaulted based on the class name.

Throws:
java.lang.Exception

getTargetNamespace

public java.lang.String getTargetNamespace()
Get the targetNamespace used in WSDL generation.


getWSDLFileLocation

public java.net.URL getWSDLFileLocation()
Get the location of the generated WSDL file. Returns null if the WSDL file has not yet been generated.


setOpenFiles

public void setOpenFiles(boolean openFiles)
                  throws java.lang.Exception
Set whether you want the web services log window to appear, and the generated files to be opened. This property is transient and will not be persisted in the model, so should be set each time. The default is true, although it will always be false when commit is called with showUI set to false.

Throws:
java.lang.Exception

isReadOnly

public boolean isReadOnly()
Is this WebServiceModel read only?


getDependents

public java.lang.String[] getDependents()
Get the stubs and skeletons which have a dependency on this web service.

Returns:
An array of qualified class names.

getContainer

public oracle.jdevimpl.webservices.ide.WebServicesContainer getContainer()
Get the WebServicesContainer for this web service.


useAPIContext

public void useAPIContext(boolean useAPIContext)

addModelListener

public void addModelListener(WebServiceModelListener wsModelListener)
                      throws java.lang.Exception
Register a listener to events generated by this WebServiceModel.

Throws:
java.lang.Exception

removeModelListener

public void removeModelListener(WebServiceModelListener wsModelListener)
                         throws java.lang.Exception
Remove a registered WebServiceModel listener.

Throws:
java.lang.Exception

commit

public boolean commit(boolean showUI)
               throws java.lang.Exception
Commit the changes to the model and generate a web service, which consists of: A web service container. Deployment descriptors (web.xml and method selector interface). A web service WAR deployment profile.

Parameters:
showUI - whether to show the web service publishing wizard during generation.
Throws:
java.lang.Exception

rollback

public void rollback()
              throws java.lang.Exception
Rollback any addMethod(), updateMethod() or unpublishMethod() operations since the last commit().

Throws:
java.lang.Exception

remove

public void remove()
            throws java.lang.Exception
Remove this web service, deleting the container, WSDL and interface deployment descriptor, and remove the relevant web.xml entries.

Throws:
java.lang.Exception

remove

public void remove(boolean notify)
            throws java.lang.Exception
Remove this web service, deleting the container, WSDL and interface deployment descriptor, and remove the relevant web.xml entries.

Parameters:
notify - Notify any listening entities that a web service has been removed.
Throws:
java.lang.Exception

startEmbeddedServer

public void startEmbeddedServer()
                         throws java.lang.Exception
Start this web service in the embedded OC4J server. The web service must have been generated already or an Exception will be thrown.

Throws:
java.lang.Exception

terminateEmbeddedServer

public void terminateEmbeddedServer()
                             throws java.lang.Exception
If it is running, terminate the embedded OC4J server running this web service.

Throws:
java.lang.Exception

getWebServiceMethods

public oracle.jdevimpl.webservices.wsdl.WebServiceMethod[] getWebServiceMethods()

getMethods

public MethodSignature[] getMethods()
Get the methods currently defined on the WSDL file.


addMethod

public void addMethod(MethodSignature method)
               throws java.lang.Exception
Add a method to both the WSDL file and the web service class. This does not take effect until commit is called. For the method added to the web service class an empty implementation is added, along with a webmethod javadoc tag to mark the method as being part of the web service.

Throws:
java.lang.Exception

unpublishMethod

public void unpublishMethod(MethodSignature method)
                     throws java.lang.Exception
Unpublish the method from the WSDL file (i.e. stop it from being published as part of the web service) and remove the javadoc tag from the method on the web service class. The implementation of the method on the web service class is not removed.

Throws:
java.lang.Exception

updateMethod

public void updateMethod(MethodSignature oldMethod,
                         MethodSignature newMethod)
                  throws java.lang.Exception
Unpublish the webmethod javadoc tag from the old method on the web service class (but do not remove the method itself). Remove the old method from the WSDL file. If the new method does not yet exist, create it in the web service class and add the webmethod javadoc tag. If it does already exist, simply add the webmethod javadoc tag to it. Then add the new method to the WSDL file.

Throws:
java.lang.Exception

createImplementation

public void createImplementation(java.lang.String clazz)
Create a web service implementation class.


performMethodUpdates

public void performMethodUpdates()
Add, unpublish and update methods.


refactor

public void refactor(java.lang.String newWebServiceClass)
              throws java.lang.Exception
Throws:
java.lang.Exception

signaturesEqual

public boolean signaturesEqual(MethodSignature sig1,
                               MethodSignature sig2)
Compare the two supplied method signatures, and check whether they are the same.

Parameters:
sig1 - First signature to compare.
sig2 - Second signature to compare.
Returns:
True if the signatures are the same, false otherwise.

Extension SDK

 

Copyright ©1997, 2003, Oracle. All rights reserved.