aspose file tools*
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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "getSOAPBody gives NoSuchMethod" Watch "getSOAPBody gives NoSuchMethod" New topic
Author

getSOAPBody gives NoSuchMethod

mark weitz
Greenhorn

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:

C:\Sun\jwsdp-1.6/saaj/lib/saaj-api.jar;
C:\Sun\jwsdp-1.6/saaj/lib/saaj-impl.jar;
C:\Sun\jwsdp-1.6/jwsdp-shared/lib/commons-logging.jar;
C:\Sun\jwsdp-1.6/jwsdp-shared/lib/mail.jar;
C:\Sun\jwsdp-1.6/jwsdp-shared/lib/activation.jar;
C:\Sun\jwsdp-1.6/jaxp/lib/endorsed/dom.jar;
C:\Sun\jwsdp-1.6/jaxp/lib/endorsed/xercesImpl.jar;
C:\Sun\jwsdp-1.6/jaxp/lib/endorsed/sax.jar;
C:\Sun\jwsdp-1.6/jaxp/lib/endorsed/xalan.jar;

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

SOAPMessage reply = connection.call(message,
"http://services.xmethods.net:80/soap/servlet/rpcrouter");
connection.close();

System.out.println("\n\nRESPONSE:\n");
reply.writeTo(System.out);

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

SOAPBody soapBody = reply.getSOAPBody();

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


And the results that get printed to my console:

RESPONSE:

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xm
lns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org
/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getPriceResponse xmlns:ns1="urn:xmethods-BNPriceCheck" SOAP-ENV:encodingSty
le="http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:float">-1.0</return>
</ns1:getPriceResponse>

</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
before getSOAPBody
Exception in thread "main" java.lang.NoSuchMethodError: javax.xml.parsers.SAXPar
serFactory: method getSchema()Ljavax/xml/validation/Schema; not found
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.<init>(Unknown
Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl.newSAXPa
rser(Unknown Source)
at com.sun.xml.messaging.saaj.util.ParserPool.get(ParserPool.java:42)
at com.sun.xml.messaging.saaj.soap.EnvelopeFactory.createEnvelope(Envelo
peFactory.java:62)
at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelope
FromSource(SOAPPart1_1Impl.java:39)
at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl
.java:98)
at com.sun.xml.messaging.saaj.soap.MessageImpl.getSOAPBody(MessageImpl.j
ava:768)
at SendSOAP.main(SendSOAP.java:55)


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();
setTargetEndpointAddress(endpoint);
call.setOperationName("method you are calling");

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

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

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

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
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.



-Tim
Mani Krishnan
Greenhorn

Joined: Sep 04, 2005
Posts: 1
Hi,

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.
<JAVA_HOME>/jre/lib/endorsed
2. Copy the jar files from the below directory where WSDP 1.6 installed in your machine.
<WSDP_HOME>/jaxp/lib
<WSDP_HOME>/jaxp/lib/endorsed
3. Paste all the jar files newly created directory <JAVA_HOME>/jre/lib/endorsed

Let me know if you still face any problem.

Thanks,
Mani
Siva Balasundaram
Greenhorn

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 com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)

any other suggestions

Regards
Siva
Siva Balasundaram
Greenhorn

Joined: Dec 12, 2004
Posts: 9
Hi Mani

It worked fine thanks.

regards
Siva
mark weitz
Greenhorn

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: getSOAPBody gives NoSuchMethod