Oracle® Application Server Web Services Developer's Guide 10g (10.1.3.1.0) Part Number B28974-01 |
|
|
View PDF |
This appendix describes the Oracle implementation of the Java APIs for WSDL version 1.1 (OraWSDL). These APIs allow you to read, modify, write, create, and re-organize WSDL documents in memory.
The key Java API for WSDL is the javax.wsdl.factory.WSDLFactory
class. This abstract class enables applications to obtain a WSDL factory capable of producing new definitions, new WSDLReaders
, and new WSDLWriters
.
See Also: The Java APIs for WSDL version 1.1 at the following Web site: |
The OracleAS Web Services implementation of the javax.wsdl.factory.WSDLFactory
class is oracle.webservices.wsdl.WSDLFactoryImpl
. Use this class to create new WSDL factory instances. As the abstract WSDLFactory
class requires, OracleAS Web Services provides extensions to support XMLSchema, SOAP, HTTP, and MIME.
The WSDL_READ_TIMEOUT
property can be used only with the HTTP or HTTPS protocols. This property specifies the maximum amount of time, in seconds, that the WSDLReader
implementation waits to receive a response to a request for a remote WSDL definition.
Here are a few examples of where you can use the functionality provided by the WSDLFactory
class.
writing a WSDL manipulation tool
programmatically analyzing a WSDL
writing WSIF provider
Example B-1 provides sample code that uses the Java APIs for WSDL to get and manipulate a WSDL file. The samples illustrate the following tasks.
creating a WSDL file reader and registering the standard extensions
setting a timeout for reading the WSDL definition
reading a WSDL file
getting information from a WSDL file
In the lines of code that get a WSDL factory, note that the WSDLFactory.newInstance
method uses the Oracle WSDLFactoryImpl
class to create the WSDL factory instance.
Example B-1 Using the Java APIs for WSDL to Manipulate a WSDL
...
//--Get the WSDLFactory. You must specifiy Oracle's implementation class name
WSDLFactory wsdlFactory = WSDLFactory.newInstance("oracle.webservices.wsdl.WSDLFactoryImpl");
...
//--Create a reader and register the standard extensions
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
ExtensionRegistry extensionRegistry = wsdlFactory.newPopulatedExtensionRegistry();
wsdlReader.setExtensionRegistry(extensionRegistry);
...
//--Set a sixty-second timeout for reading the WSDL definition
System.setProperty(oracle.webservices.wsdl.WSDLFactoryImpl.WSDL_READ_TIMEOUT, "60" );
...
//--Read a WSDL file, including any imports
Definition def = wsdlReader.readWSDL("http://some.com/someservice?WSDL");
...
//--You can now explore the WSDL definition, for example,
Map services = def.getServices();
String targetNamespace = def.getTargetNamespace();
...
The code in Example B-2 demonstrates how you can get the WSDL by using methods in the javax.xml.rpc.server.ServletEndpointContext
and javax.servlet.ServletContext
classes. The WSDL is obtained and stored as an InputStream
. This technique works not only for the WSDL, but for any resource.
The // code to handle the input stream
section indicates where you can insert OraWSDL API code similar to the samples in Example B-1 to get and manipulate the WSDL file.
Example B-2 Getting the WSDL as a Resource
public class HelloImpl implements javax.xml.rpc.server.ServiceLifecycle { // default constructor public HelloImpl() { } public init(Object context){ javax.xml.rpc.server.ServletEndpointContext ctx = (javax.xml.rpc.server.ServletEndpointContext) context; javax.servlet.ServletContext servletContext= ctx.getServletContext(); //we can read any other resource the same way. java.io.InputStream wsdlDocument = servletContext.getResourceAsStream("/WEB-INF/wsdl/MyWsdl.wsdl")) ; // code to handle the input stream ... } //empty implementation public void destroy() {} // sayHello method public String sayHello(String name) { return ("Hello " + name + "!"); } }