This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Web Services and the fly likes getSOAPBody gives NoSuchMethod Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "getSOAPBody gives NoSuchMethod" Watch "getSOAPBody gives NoSuchMethod" New topic

getSOAPBody gives NoSuchMethod

mark weitz

Joined: Aug 08, 2001
Posts: 10
I'm trying to work though some SOAP samples but keep hitting the same problem.
I've created my SOAP message, sent it, and got a response back. I can print the response using response.writeTo(System.out) and see that I get a good response. Now I'm trying to do something with the response. All the examples show getting the body of the response with response.getSOAPBody(). However I keep getting a NoSuchMethod exception.

I am running J2RE 1.4.1.

I am using jwsdp-1.6 with the following classpath:


Here's part of the code that sends the message and trys to get the SOAP body.

SOAPMessage reply =,


System.out.println("before getSOAPBody");

SOAPBody soapBody = reply.getSOAPBody();

System.out.println("after getSOAPBody");

And the results that get printed to my console:


<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="" xm
lns:xsi="" xmlns:xsd="
<ns1:getPriceResponse xmlns:ns1="urn:xmethods-BNPriceCheck" SOAP-ENV:encodingSty
<return xsi:type="xsd:float">-1.0</return>

before getSOAPBody
Exception in thread "main" java.lang.NoSuchMethodError: javax.xml.parsers.SAXPar
serFactory: method getSchema()Ljavax/xml/validation/Schema; not found
rser(Unknown Source)
at com.sun.xml.messaging.saaj.util.ParserPool.get(
at com.sun.xml.messaging.saaj.soap.EnvelopeFactory.createEnvelope(Envelo
at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelope
at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl
at com.sun.xml.messaging.saaj.soap.MessageImpl.getSOAPBody(MessageImpl.j
at SendSOAP.main(

Any ideas on how to overcome this problem?
dale con
Ranch Hand

Joined: Apr 15, 2005
Posts: 93
try something like this

URL endpoint = "http://......"
Service service = new Service();
Call call = (Call)service.createCall();
call.setOperationName("method you are calling");

String result = (String)call.invoke(new Object[]{params if any});

Message message = call.getResponseMessage();
SOAPEnvelope envelope = message.getSOAPEnvelope();

I haven't tried this so don't know whether it will work
mark weitz

Joined: Aug 08, 2001
Posts: 10
Thanks for the alternate code.

I have sort of solved the problem for now.

Rather than using jwsdp 1.6 I have downloaded v 1.4. Using the 1.4 jaxp and saaj classes I was able to get the getSOAPBody method work. I am still bothered that my v 1.6's jaxp and saaj do not work in harmony for getSOAPBody.

Anyone have any thoughts on this?
Tim West
Ranch Hand

Joined: Mar 15, 2004
Posts: 539
Based on this, you need a 1.4.2 or greater JRE. Dunno whether that'd be causing this problem though.

Tim West
Ranch Hand

Joined: Mar 15, 2004
Posts: 539
Ugh, it won't - the method that causes the error doesn't exist in JDK1.4.2 either.

Mani Krishnan

Joined: Sep 04, 2005
Posts: 1

Even i faced the same problem. But i resolved it. Pls follow the below steps to resolve this problem.
1. Create the below directory where JDK installed in your machine.
2. Copy the jar files from the below directory where WSDP 1.6 installed in your machine.
3. Paste all the jar files newly created directory <JAVA_HOME>/jre/lib/endorsed

Let me know if you still face any problem.

Siva Balasundaram

Joined: Dec 12, 2004
Posts: 9
Hi Mani

I still facing the same problem even after following your suggestions.

Error message is
Exception in thread "main" java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory: method getSchema()Ljavax/xml/validation/Schema; not found
at<init>(Unknown Source)
at Source)

any other suggestions

Siva Balasundaram

Joined: Dec 12, 2004
Posts: 9
Hi Mani

It worked fine thanks.

mark weitz

Joined: Aug 08, 2001
Posts: 10
Mani was on the right path. Here is another answer I received from a Sun JAXP site. I have not tried this solution.

To run your class with JRE1.4.2, you need to use endorsed mechanism, as shown below:
java -Djava.endorsed.dirs=<directory of jaxp jar files> UddiPing

JRE uses the classes which are bundled in it by default. So, it doesn't help
even if you set CLASSPATH to appropriate jars. To override the deafult jars, you
need to use endorsed way.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: getSOAPBody gives NoSuchMethod
It's not a secret anymore!