You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by Scott Cantor <sc...@yahoo.com> on 2002/07/23 05:56:17 UTC

WebLogic deployment tip

Here is a tip for people who want to use Apache SOAP
2.3.1 with BEA WebLogic 7.0 (and probably earlier..
6.1, etc.).  If you're like me, you've noticed that it
doesn't work "out of the box" if you want to include
the soap.xml config file in your WAR file.  Why? 
Because the code artists here think every application
server will unpack a WAR file, so Apache SOAP assumes
it can do a new File(...) on your Config file param. 
I want to do this:

<context-param>
   <param-name>ConfigFile</param-name>
   <param-value>/WEB-INF/soap.xml</param-value>
</context-param>

Works in OC4J, Tomcat, etc.  In WLS you're screwed. 
It's not WLS's fault though, because the Servlet 2.3
spec doesn't require the container to unpack the WAR
file.

Solution:

1) Obtain and unpack the source and binary
distributions for Apache SOAP 2.3.1.

2) Modify org/apache/soap/server/ServiceManager.java
as follows:


***********************************
OLD
***********************************

private void readConfigFile() {
  FileReader        reader = null ;
  Document          doc    = null ;
  Element           elem   = null ;
  NodeList          list   = null ;
  int               i, k ;
  Hashtable         options = null ;

  try {
    File configFile =
     
ServerHTTPUtils.getFileFromNameAndContext(configFilename,
context);

    reader = new FileReader(configFile);
    doc = xdb.parse(new InputSource(reader));
    ....
      
***********************************
NEW
***********************************

private void readConfigFile() {
  FileReader        reader = null ;
  Document          doc    = null ;
  Element           elem   = null ;
  NodeList          list   = null ;
  int               i, k ;
  Hashtable         options = null ;

  try {
    File configFile =
     
ServerHTTPUtils.getFileFromNameAndContext(configFilename,
context);

    if (configFile != null && configFile.exists())
    {
       // this is original Apache SOAP way of loading
file; doesn't work 
       // if file is inside an unopened WAR
       reader = new FileReader(configFile);
       doc = xdb.parse(new InputSource(reader));
    }
    else
    {
       // this uses standard servlet API to extract
the file as a resource
       InputStream is =
context.getResourceAsStream(configFilename);

       try
       {
       doc = xdb.parse(is);
       }
       finally
       {
          is.close();
       }
    }
    ....

3) Rebuild soap.jar by running "ant" in the directory
for (1).


Also if you're like me, you want to use the same
conventions for the XML deployment descriptor file,
e.g.
  
***********************************
soap.xml
***********************************

<?xml version="1.0"?>
 
 <!-- Apache SOAP Server Configuration File -->
 <soapServer>
   <configManager
value="org.apache.soap.server.XMLConfigManager">
     <option name="filename"
value="/WEB-INF/my-awesome-ws.xml"/>
   </configManager>
 </soapServer>
  

The solution is about the same:

1) Ditto.
2) Modify org/apache/soap/server/XMLConfigManager.java
as follows:

***********************************
OLD
***********************************

public void loadRegistry() throws SOAPException {
  dds = null ;
  try {
    File file =
ServerHTTPUtils.getFileFromNameAndContext(filename,
      context);
    FileReader rd = new FileReader (file);
    Document doc = null;
    Element root = null;

    try {

      
      doc  = xdb.parse(new InputSource(rd));
      ....

***********************************
NEW
***********************************

public void loadRegistry() throws SOAPException {
  dds = null ;
  try {
    File file =
ServerHTTPUtils.getFileFromNameAndContext(filename,
      context);
    Document doc = null;
    Element root = null;

    try {

       if (file != null && file.exists())
       {
          // this is original Apache SOAP way of
loading file; doesn't work 
          // if file is inside an unopened WAR
          FileReader rd = new FileReader (file);
          doc  = xdb.parse(new InputSource(rd));
       }
       else
       {
          // this uses standard servlet API to extract
the file as a resource
          InputStream is =
context.getResourceAsStream(filename);

          try
          {
          doc = xdb.parse(is);
          }
          finally
          {
             is.close();
          }
       }
       ....

3) Ditto.

Note to Apache SOAP 2.3 authors/maintainers:  In the
real world people use things called "EARs" and "WARs"
to package and deploy applications.  These things lose
their utility if deployers have to manually install
application configuration files elsewhere on the hard
disk.


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

--
To unsubscribe, e-mail:   <ma...@xml.apache.org>
For additional commands, e-mail: <ma...@xml.apache.org>