This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Cant find the correct SOAPMessage  class for SAAJ eg. RMH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Cant find the correct SOAPMessage  class for SAAJ eg. RMH" Watch "Cant find the correct SOAPMessage  class for SAAJ eg. RMH" New topic
Author

Cant find the correct SOAPMessage class for SAAJ eg. RMH

Dhiren Joshi
Ranch Hand

Joined: Dec 09, 2003
Posts: 463
Hi ,
I have this piece of code snippet of SAAJ example from RMH
<<
MessageFactory msgFactory =MessageFactory.newInstance();
SOAPMessage message = msgFactory.createMessage();
message.getSOAPHeader().detachNode();
SOAPBody body=message.getSOAPPart();
SOAPElement getBookPrice=body.addChildElement("getBookPrice","mh","http:/www.Monson-Hafel.com/jwsbook/BookQuote");
getBookPrice.setEncodingStyle(SOAPConstants.URI_NS_SOAP_ENCODING);>>

Oddly enough the webservice developer pack 1.3 whihc I have doesnt give me support for this API.
SOAPMessage message = msgFactory.createMessage();
// I cant do message.getSOAPHeader() as that API call is not there .
message.getSOAPHeader().detachNode();

My SOAPMessage class doesnt have this method call . getSOAPHeader()
Can anyone tell me how to fix this problem.
I semed to have the wrong jar file somehow.

I have all these files in the classpath
D:\jwsdp-1.3\
jaxr\lib\jaxr-api.jar;D:\jwsdp-1.3\jaxr\lib\jaxr-impl.jar;.;D:\jwsdp-1.3\jaxb\li
b\jaxb-impl.jar;D:\jwsdp-1.3\jaxb\lib\jaxb-api.jar;D:\jwsdp-1.3\jaxrpc\lib\jaxrp
c-impl.jar;D:\jwsdp-1.3\jaxrpc\lib\jaxrpc-api.jar;D:\jwsdp-1.3\saaj\lib\saaj-imp
l.jar;D:\jwsdp-1.3\saaj\lib\saaj-api.jar;D:\jwsdp-1.3\jaxb\jaxb-libs.jar;D:\jwsd
p-1.3\jaxb\lib\jaxb-libs.jar;D:\jwsdp-1.3\jwsdp-shared\lib\relaxngDatatype.jar;D
:\jwsdp-1.3\jwsdp-shared\lib\namespace.jar;D:\jwsdp-1.3\jwsdp-shared\lib\mail.ja
r;D:\jwsdp-1.3\jwsdp-shared\lib\activation.jar;D:\jwsdp-1.3\jaxp\lib\xercesImpl.
jar;D:\jwsdp-1.3\jaxp\lib\endorsed\xercesImpl.jar;D:\jwsdp-1.3\jaxp\lib\endorsed
\dom.jar;D:\jwsdp-1.3\jaxp\lib\xsdlib.jar;D:\jwsdp-1.3\jwsdp-shared\lib\xsdlib.j
ar

Thanks
Dhiren
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3211
    
    6
hi

here is reduced code of SOAPMessage class:



as you can see - there is "getSOAPHeader" method there

another approach -

message.getSOAPPart().getHeader().

more details about SAAJ API - here

regards,
mz


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Dhiren Joshi
Ranch Hand

Joined: Dec 09, 2003
Posts: 463
Yeah .. That is the issue .
I looked in SAAJ API its there but in my WSAD .It doesnt show up .
getSOAPHeader() method is not there.
And if I add that call to SOAPMessage I get a broken compile showing .
So somehow I have the incorrect jar file.

Any one can help.
Thanks
Dhiren
Richard Monson-Haefel
author
Ranch Hand

Joined: Oct 31, 2003
Posts: 92
JWSDP 1.3 uses SAAJ 1.1 while J2EE 1.4 uses SAAJ 1.2. SAAJ 1.2 added the methods in question. In other words, they are defined in SAAJ 1.2 but not SAAJ 1.1. Since you are supposed to know SAAJ 1.2, you should not continue to study the SAAJ 1.1 API in JWSDP 1.3 - why aren't you working with the J2EE 1.4 SDK? (Actually I find that SDK very difficult to work with so there is really no mystery there. ;-)


-- <br />Richard Monson-Haefel<br /><a href="http://www.Monson-Haefel.com" target="_blank" rel="nofollow">http://www.Monson-Haefel.com</a>
matt tee
Greenhorn

Joined: Jun 25, 2004
Posts: 2
Sorry to bump this thread but I am getting the same error. I have updated to SaaJ 1.2 (using the saaj jars from JWSDP 1.4) but it *still* comes up with an error message saying 'method not found - getSOAPHeader' when I try to run the servlet in websphere. I've added the jars to the build path of the project. I'm using websphere AD 5.1.

Any ideas why this is happening much appreciated. It's driving me mad. It's probably something really obvious as well...
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3211
    
    6
Hello Matt,

[offtopic]

As far as I understand, you are using WSAD .

To resolve you problem with methods visibility try to move to the top new SAAJ jar file. It looks like old SAAJ API still in projects CLASSPATH and has higher priority.

To do this:

1. Right Click on project, select "Properties",
2. Then select "Java Build Path" in the left side,
3. Then select Tab "Order and Export",
4. Highlight new SAAJ jar file and move it to the top (button Up)
5. Restart project.

[/offtopic]

cheers,
MZ
matt tee
Greenhorn

Joined: Jun 25, 2004
Posts: 2
Thanks for the reply, and sorry about taking the thread off topic

I'd moved the saaj apis up in the build path order already, but the problem was still there. I figured out it is the server that is the problem - so I put the apis in the server's classpath and got into all sorts of conflicts. I'll tackle that today.

I wonder if anyone knows the answer to this question:
Does SaaJ 1.2 support literal encoding of documents? At the moment my message gets encoded using soap's multiref array encoding, but I want it to send it literally using no soap encoding. If I manage to sort out the classpath problem above, does saaj 1.2 support literal encoding?

Any help much appreciated (and I've sort of brought it back on topic again now)

Thanks,

Matt
 
GeeCON Prague 2014
 
subject: Cant find the correct SOAPMessage class for SAAJ eg. RMH