• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Converting a SOAP file/string to message - Help for a $

Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a SOAP message I coding by hand to mimic the response a server should send me if I sent a SOAP message and got a response back (since I can't atm get a response I just added what I thought I would get back to a .xml file and read it in)

All seemed to work fine until I wanted to get a value out of the SOAP message...

This is my message dumped into a file:

Using the following:

I managed to get the message and use message.writeTo(System.out) to print out what I actually expected to see:

So there I thought I had solved the conversion of a) file input to soap message and what follows, b) string conversion to soap message...

Alas, it was not to be... The next thing I wanted to do was to try and retrieve the success_or_failure value and use it for something, to do that I should need the SOAPBody so away I went again, only to be granted sight of the following exception: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source:

Since the message printed okay using message.writeTo(System.out) I was somewhat mullified...

Any ideas greatly appreciated!
Posts: 2968
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the suspicion that writeTo() only outputs the stream while getSOAPBody() actually initiates the stream parse. Your best bet is to start with a simple working example (like the one in this topic - it works with the Apache SAAJ) and convert it to using a FileInputStream. If that works replace the SOAP message in the file with your SOAP message. If that fails to parse, gut the contents of the envelope - once it starts to work build the envelope contents up again until it doesn't work. In other words, if you can get a simple SOAP message to work with a FileInputStream then there must be something peculiar in your SOAP message.
    Bookmark Topic Watch Topic
  • New Topic