Tim Sawyer wrote:

On Wednesday 11 Aug 2004 17:50, Dennis Sosnoski wrote:


You can't really work with an Integer in isolation, since you're
probably not going to want to bind the java.lang.Integer class to a
particular element name (might work for your very simple case, but will
definitely cause problems for more complex ones).



I think what Axis does is uses the method parameter name from the java service implementation as the tag name. I was kind of hoping to do that, so an addition service that took two integers would be called with


<addition>
 <param1>5</param1>
 <param2>10</param2>
</addition>

and I presume the WSDL will be able to expose this. (I need to look into the WSDL stuff a bit more to understand it better.)


Yes, this ties into the WSDL and the binding definition as well. The JiBX way of representing this call would be using a class that holds the parameter values, in this case something like:

public class AdditionParams {
 private int value1;
 private int value2;
 ...
}

Then the binding definition would convert this to and from the XML structure you gave above. See my original remarks below.



I think the best way to handle things is with a class that represents
the full data in a message (so corresponds to a top-level element in the
XML, using doc/lit). You can define a binding for that class, which has
an Integer component. On the client side, a stub method can populate an
instance of that class with the data being passed as parameters, then
hand it off to JibxSoap for marshalling. On the server side, JibxSoap
would need to unwrap the object to an array of object references for the
parameters, then pass those using reflection.



I was toying yesterday with having a SOAPCallParameters class, which implements IMarshallable and IUnmarshallable, and contains a Vector of IMarshallable instances. This could then be passed to the call method as a single parameter, and would have the following implementation for marshall


 public void marshal(IMarshallingContext pCtx) throws JiBXException
 {
   Iterator lIterator = this.parameters.iterator();

   while (lIterator.hasNext())
   {
     IMarshallable lObject = (IMarshallable) lIterator.next();
     lObject.marshal(pCtx);
   }
 }

Will this work, or am I barking up the wrong conifer?


While this would work (at least for complex types - it would have a problem with Integer and such, which cannot be made to implement IMarshallable and IUnmarshallable), it wouldn't really satisfy most web service users who want to have a stub method that matches the parameter list they're expecting to use for the service.

<>
Can you add me a little change in while you're changing jibx-soap?

In org.jibx.soap.server.SOAPServer, at around line 170, you do:

Object response = method.invoke(null, args);

to run the method that the service is implemented in.

If you change it to the following, then it's possible to run non-static
methods too:

// if method is not static, we need an instance to pass to
// invoke method
Object lInstance = null;
if (!Modifier.isStatic(method.getModifiers()))
{
// method we are calling is not static, create instance
lInstance = method.getDeclaringClass().newInstance();
}

Object response = method.invoke(lInstance, args);

ta.

The problem with this is that it creates a new instance for each call, which generally is not going to be what you want. Using a static method allows this to be done by the static call, if that's what a user wants. To do this right I'd create an instance at the same time the SOAPServer is created, then just reuse that instance. That's probably easy enough to do - I'll think about it, at least, but want to make sure I'm not painting myself into a corner.

 - Dennis


------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ jibx-devs mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to