[SoapRMI] parameter mapping [Re: gsi is very slow with XSOAP]
Aleksander Slominski
aslom_at_cs.indiana.edu
Wed, 27 Mar 2002 23:42:17 -0500
Warren Smith wrote:
> We've been playing with Java XSOAP a
> bit and we've noticed a couple of things. Before the questions, I think
> it's pretty slick and I like it a lot. Much faster to get going with
> than Apache SOAP.
thanks for kind words :-)
> First, the parameters you pass during a method call C are named C, p2,
> p3, ... It seems to me the names should be the names of the parameters.
> Are you following a standard or is this just an artifact of using
> introspection?
in java there is no standard way to get parameter names (unfortunately)
if the class was compiled with debug info it is possible to extract from debugging
info names of parameters but it is not reliable solution (if debug info is not
included you can not do much ..) and requires special 'super' introspection
libraries ...
in XSOAP version 1.2.11+ you can easily map parameter names to any name you like
and it works as demonstrated on this example that maps sayHello method of
HelloService interface:
public interface HelloService extends Remote {
public String sayHello(String name) throws RemoteException;
}
public class HelloServiceMapping {
public static void init() throws XmlMapException
{
XmlJavaMapping javaMapping =
soaprmi.soaprpc.SoapServices.getDefault().getMapping();
XmlJavaPortTypeMap portMap =
javaMapping.queryPortType(HelloService.class);
// extracxt mapping for operation
XmlJavaOperationMap oMap = portMap.queryMethodRequest("sayHello");
// get in maessage and chane its part name
XmlJavaMessageMap requestMsg = oMap.getRequest();
XmlJavaPartMap[] reqParts = requestMsg.getParts();
reqParts[0].setPartName("name");
// get out message and change name of output
XmlJavaMessageMap responseMsg = oMap.getResponse();
XmlJavaPartMap[] resParts = responseMsg.getParts();
resParts[0].setPartName("result");
}
}
i have added this code to CVS so if you cvs update -dP to the latest xsoap-java you
can run this sample, first configure XSOAP logger to show tracing info:
set JAVA_OPTS=-Dsoaprmi.trace
then start server in separate window (on UNIX use xterm first):
C:\Forge\codes\xsoap\java>start run hello_server 3440
and now execute client:
C:\Forge\codes\xsoap\java>run hello_client http://localhost:3440
JAVA_HOME=c:\jdk1.3
c:\jdk1.3\bin\java -Dlog=soaprmi.trace -cp
build\classes;build\samples;build\tests;lib\cog\iaik_ssl
.jar;lib\cog\iaik_jce_full.jar;lib\cog\cryptix.jar;lib\cog\cog-20011108.jar;lib\jsse\jsse.jar;lib\js
se\jnet.jar;lib\jsse\jcert.jar;lib\wsdl\wsdl4j_0_8.jar;lib\servlet_api\servlet22.jar;lib\junit\junit
37.jar; hello.HelloClient http://localhost:3440
Logger $Revision: 1.8 $ $Date: 2002/03/06 00:06:28 $ (GMT) configured as
'soaprmi.trace'
Client executing remote method sayHello on server with 'World' argument
[ main: MethodInvoker.java:310 sendRequest ] TRACE sending len=431:---
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:SOAP-ENC='http:/
/schemas.xmlsoap.org/soap/encoding/'
xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance' xmlns:xsd
='http://www.w3.org/1999/XMLSchema'
SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding
/'>
<SOAP-ENV:Body>
<m:sayHello xmlns:m='urn:hello:sample'>
<name>World</name>
</m:sayHello>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
---
[ main: MethodInvoker.java:323 receiveResponse ] TRACE reading response to buffer
[ main: MethodInvoker.java:333 receiveResponse ] TRACE received: len=581
---
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:SOAP-ENC='http:/
/schemas.xmlsoap.org/soap/encoding/'
xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance' xmlns:xsd
='http://www.w3.org/1999/XMLSchema'
SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding
/'>
<SOAP-ENV:Body>
<m:sayHelloResponse xmlns:m='urn:hello:sample'>
<result xsi:type='xsd:string'>Hello from Indiana to World (connection received from
Socket[addr=127.
0.0.1/127.0.0.1,port=1603,localport=3440])!</result>
</m:sayHelloResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
---
Server said 'Hello from Indiana to World (connection received from
Socket[addr=127.0.0.1/127.0.0.1,p
ort=1603,localport=3440])!'
as you can see parameter name is 'name' and return name is 'result'
i was also thinking about some metadat for java interfaces as XML to make it easier
tomap parameter names (and of couse castor support fo rliteral encoding to offload
generation of XML conforming to XML schema to code designed for it ...)
thanks,
alek