Hi All,

I'm currently trying to use the Apache SOAP RPCProvider to access a COM
object and I have met a strange behavior.

This COM object has 3 methods :
- GetInt which returns a hardcoded short integer (no parameters),
- GetString which returns a hardcoded string (no parameters),
- GetRecordset which returns a string from a database (one string as
parameter).

We have used this COM object to verify access from a WebSphere server and a
WebLogic server (via some Java-COM bridges like J-Integra or R-Jax) and all
was OK. Now we are trying to access that object from Tomcat 3.2.2 via Apache
SOAP 2.2. The GetString method is OK, but the GetInt doesn't return the good
result.

The SOAP request message is :
POST /soap/servlet/rpcrouter HTTP/1.0
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: 397
SOAPAction: ""

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<SOAP-ENV:Body>
<ns1:GetInt xmlns:ns1="urn:Java-COM"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
</ns1:GetInt>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The SOAP response message is :
HTTP/1.0 500 Internal Server Error
Content-Type: text/xml; charset=utf-8
Content-Length: 1765
Set-Cookie2: JSESSIONID=fmo9pcntt1;Version=1;Discard;Path="/soap"
Set-Cookie: JSESSIONID=fmo9pcntt1;Path=/soap
Servlet-Engine: Tomcat Web Server/3.2.2 (JSP 1.1; Servlet 2.2; Java 1.2.2;
Windows NT 5.0 x86; java.vendor=Sun Microsystems Inc.)

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>COMProvider: native code exception:[SOAPException:
faultCode=SOAP-ENV:Server; msg=Failed to get dispid for method
GetInt]</faultstring>
<faultactor>/soap/servlet/rpcrouter</faultactor>
<detail>
<stackTrace>[SOAPException: faultCode=SOAP-ENV:Server; msg=COMProvider:
native code exception:[SOAPException: faultCode=SOAP-ENV:Server; msg=Failed
to get dispid for method GetInt]]
        at org.apache.soap.providers.com.RPCProvider.invoke(RPCProvider.java:200)
        at org.apache.soap.server.http.RPCRouterServlet.doPost(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
        at org.apache.tomcat.core.Handler.service(Handler.java:287)
        at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
        at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
        at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:213)
        at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java,
Compiled Code)
        at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java,
Compiled Code)
        at java.lang.Thread.run(Thread.java:479)
</stackTrace>
</detail>
</SOAP-ENV:Fault>

In the faultstring, the name of the method GetInt is followed par a strange
character, which is not always the same. This character seems to be the
cause of the problem in the JNI part of the provider.

The Apache deployment descriptor is the following :
<!--Apache SOAP specific deployment descriptor (ie loads this service into
Apache SOAP.-->
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment";
id="urn:Java-COM">
  <isd:provider type="org.apache.soap.providers.com.RPCProvider"
                scope="Application"
                methods="GetString GetInt GetRecordset">
    <isd:java class="required not needed for COMProvider"/>
    <isd:option key="progid" value="Comtest.cComtest" />
  </isd:provider>

<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListene
r>
</isd:service>

The Java code is :
package samples.com.client;

import java.io.*;
import java.net.*;
import java.util.*;

import org.apache.soap.*;
import org.apache.soap.rpc.*;

public class GetInt
{
 public static void main( String[] args) throws Exception
 {

   final String urn= "urn:Java-COM";

   Vector params = new Vector ();
   URL url = new URL ("http://"; + serverhost + ":" + serverport+
soapservlet);

   // Build the call.
   Call call = new Call ();
   call.setTargetObjectURI (urn);
   call.setMethodName ("GetInt");
   call.setEncodingStyleURI (Constants.NS_URI_SOAP_ENC);

   call.setParams (params);
   Response resp = call.invoke (/* router URL */ url, /* actionURI */ "" );

   if (resp.generatedFault ()) {
     Fault fault = resp.getFault ();
     System.out.println ("Ouch, the call failed: ");
     System.out.println ("  Fault Code   = " + fault.getFaultCode ());
     System.out.println ("  Fault String = " + fault.getFaultString ());
   } else {
     Parameter result = resp.getReturnValue ();
     System.out.println("The result of GetInt is " + result.getValue());
   }
 }
 static String serverhost= "localhost";
 static String serverport= "7070";
 static String soapservlet= "/soap/servlet/rpcrouter";
}

Finally, I tried to access the COM object from an HTML page with the
Microsoft WebService and the GetInt method was OK.
I used the wsdlgen.exe tool from the MS SOAP Toolkit 2.0 Gold to generate
the WSDL and WSML files.
The generated files are attached to this mail.

I've tried the last Apache SOAP nightly build (23-jul-2001) and the problem
remains the same.
So, I can't figure where is the problem.

Anybody has an idea ?
Thanks very much in advance for any help.

Christian BERNARD
NAGORA Technologies

Comtest.WSDL

Comtest.wsml

Reply via email to