Results 1 to 3 of 3

Thread: Unmarshalling SOAP response using Spring

  1. #1
    Join Date
    Jan 2007
    Posts
    4

    Default Unmarshalling SOAP response using Spring

    I need to make some SOAP unmarshalling tests, but without calling actual web service. Instead I have already available SOAP response xml and WSDL xml file. What is the best approach to do this using Spring?
    Could someone point me to some documentation, examples?

    I've seen Castor example, but it needs additional mapping.xml. Is there any other approach that could help me in Object/XML mapping i.e. in unmarshalling XML (SOAP) to Java object?
    Thanx!
    Last edited by igor_b; Aug 6th, 2010 at 04:25 AM.

  2. #2
    Join Date
    Apr 2010
    Posts
    25

    Default

    Easiest thing is to use jaxb/xjc to create the java objects that correspond to your schema, then unmarshall the xml using some code like this (for library.xsd for example)

    Code:
    JAXBContext context = JAXBContext.newInstance("<package-name>") ;
    
    Unmarshaller unmarshaller = context.createUnmarshaller() ;
    
    Library library =(Library)unmarshaller.unmarshal (new FileInputStream("library.xml")) ;

  3. #3
    Join Date
    Jan 2007
    Posts
    4

    Default

    Thanx natephipps for your response!

    Well, this is good solution, just I'm searching for something different. I already have all POJOs that correspond to schema (these POJOs are in external libarary .jar file), and I have WSDL file available.
    I also have some mock web service response XMLs, that I want to use them in my tests.

    Is there some other approach that I could utilize all this in order to parse mock XMLs and bind them to available POJOs?

    Thanx
    Last edited by igor_b; Aug 11th, 2010 at 10:05 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •