• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Generate SOAP message from Java class

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

In my requirement I have to generate SOAP message from a java class.
The sending portion will be handled by a framework [ our firm has a framework built over JMS], so I just need to create a message only.

I tried to use these methods

MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();

//Create objects for the message parts
SOAPPart soapPart = message.getSOAPPart();

in a simple program but while running it throws the following exception

xception in thread "main" java.lang.NoClassDefFoundError: com/ibm/ws/ffdc/FFDCFilter
at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:197)

So, I am thinking I somehow am not proceeding correct.

Can anyone please provide suggestions ?

Thanks
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No Class Def Found Exeption usually means that the class path was not set properly,
Have you checked that all the libraries are included in classpath.
 
Atul Mishra
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gaurav,

First thanks for the reply.

I have the j2ee.jar added. But the complaint is about an IBM file.

My enironment is eclipse and I dont have [I dont need to have any IBM dependancy]

So thats why I am confused when it threw an IBM related exception

I want to use javax.xml.soap package.

Thanks
 
Atul Mishra
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could anyone please mention on how to generate SOAP message from a Java class.

Thanks
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the Web Services forum.
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use AXIOM soap api to generate soap envelope. AXIOM is provided by apache and quite handy. following link is useful as well.
http://www.nabble.com/How-to-create-a-soap-envelope-using-AXIOM--to13848521.html
dont forget to keep axiom related jar in class path, otherwise you will get classNotFound exception
 
Atul Mishra
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

use AXIOM soap api to generate soap envelope. AXIOM is provided by apache and quite handy. following link is useful as well.
http://www.nabble.com/How-to-create-a-soap-envelope-using-AXIOM--to13848521.html
dont forget to keep axiom related jar in class path, otherwise you will get classNotFound exception




Thanks for the suggestion, but unfortunately we wont be able to use any external APIs.

Can I achieve this by using SAAJ ?

Thanks
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
You can use SAAJ to create and populate SOAP messages. To make life a little easier, you can use JAXB to marshal and unmarshal the contents of the SOAP body, if you want to. Both these APIs are part of the JRE 6.
The following code shows how to create SOAP messages using SAAJ:

Best wishes!
 
Atul Mishra
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the code Ivan..

Unfortunately have a 1.5 limitation..

Trying your code now.

Please suggest on additional jars needed if using 1.5

Thanks
Atul
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isn't this kind of the same discussion as this one: https://coderanch.com/t/452113/Web-Services/java/SOAP-body-Java-client ? Maybe it should be continued in just one topic?
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in java5, you could add two more jar files: saaj.jar, saaj-api.jar. Then use the code like below:
DocumentBuilder oBuilder = oDocFactory.newDocumentBuilder();
Document oDoc = oBuilder.parse(new File("xxx"));

MessageFactory oMsgFac = MessageFactory
.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage oMessage = oMsgFac.createMessage();
SOAPBody oBody = oMessage.getSOAPBody();
oBody.addDocument(oDoc);
 
Atul Mishra
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem I am facing is the company standards
Have anyone use Artix lite to generate SOAP messages ?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic