axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Callahan <call...@gmail.com>
Subject Re: AXIS and JAXB
Date Fri, 14 Jan 2005 13:43:33 GMT
Hi Roger,

There are a couple of ways that you can integrate the two (or Axis and
any XML serializing mechanism for that matter).

One way is discussed in this article by IBM...  They are using Castor,
but the underlying theme is the same.

http://www-106.ibm.com/developerworks/webservices/library/ws-castor

Alternatively, you may use a "message" style service...  This is from
an earlier post:

---
An alternative to creating a custom serializer is to use the
doc/literal style service and use one of the 4 method signatures that
Axis allows.  You can inspect the incoming XML to determine what kind
of message you have received.  From there, use the utilities provided
by the JAXB api to translate the XML message into JAXB objects, and
perform your business logic.  Then, create output objects using JAXB
and serialize them to XML--return that from your web service method. 
So your webservice "controller" class could have a method like this:

public Document doService(Document body) throws AxisFault {

  // inspect the document to see what "kind" of message you have received..
  
  // deserialize the message
  jc = JAXBContext.newInstance(<your namespace>);
  u = jc.createUnmarshaller();
  m = jc.createMarshaller();
  requestObj = u.unmarshal(body);

  // perform your domain logic on this object

  // serialize and return your response
  returnDoc = XMLUtils.newDocument();
  m.marshal(responseObj, returnDoc);

   return returnDoc;

}

---

As for reuse of the XSD within the WSDL, you are on the right track. 
You can use import statements in your WSDL to reference the XSD
namespace.  I have not generated wsdl for a doc/lit using JAXB
before--but you should be able to by defining some interface class and
using your JAXB objects...  Then you would have to massage that output
to use your XSD instead of the schema that is generated within the
WSDL--someone please correct me if there is another best practice for
that?

Hope this helps a bit,
pc

On Fri, 14 Jan 2005 12:18:39 +0100, roger.stoffers@vodafone.com
<roger.stoffers@vodafone.com> wrote:
> Hi,
> 
> In existing applications, I am using existing XML schema's. Also I use JAXB
> to facilitate marshalling/unmarshalling in existing applications. Part of
> this application functionality I would like to expose through SOAP. JAAS may
> be used to create document/literal style messages however I would like to
> use AXIS, since it better fits my needs.
> 
> Therefore, I would like to try to include those existing schemas in my WSDL
> file but how can I use AXIS document style and also use JAXB for object
> serialization/deserialization?
> 
> Who did this before? Some hints would be appreciated, an example would be
> excellent?
> 
> Roger Stoffers
> Vodafone Netherlands
>

Mime
View raw message