Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SOAPConstants.Dynamic_Soap_Protocol Tutorial

Status
Not open for further replies.

lubywan

Programmer
Mar 27, 2009
5
US
I'm doing a tutorial at and can't get the SOAPConstants.DYNAMIC_SOAP_PROTOCOL (line 1) to be recognized (also it says that "The method addBodyElement(Name) in the type SOAPBody is not applicable for the arguments
(QName)" (line 7), "The method addChildElement(Name) in the type SOAPElement is not applicable for the arguments
(QName)" (line 8), AND "Syntax error on token ""SUNW"", delete this token" (line 9). Pretty frustrating trying to learn when you can even get the tutorials to work!!!!

(I realize that I might have overdone the imports, but I was desparate)! Once again, thanks for your time.


I have this:

import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.namespace.QName;
import javax.xml.*;

public class OrderToCash {

1 MessageFactory factory = MessageFactory.newInstance(SOAPConstants.DYNAMIC_SOAP_PROTOCOL);
2 SOAPMessage message = factory.createMessage();

3 SOAPPart soapPart = message.getSOAPPart();

4 SOAPHeader header = message.getSOAPHeader();
5 SOAPBody body = message.getSOAPBody();

6 QName bodyName = new QName(" "GetLastTradePrice", "m");
7 SOAPBodyElement bodyElement = body.addBodyElement(bodyName);

8 QName name = new QName("symbol");
SOAPElement symbol = bodyElement.addChildElement(name);
9 symbol.addTextNode("SUNW");
 
Since I have never worked on SOAP, I am not very sure....but I just went through the API documentation for javax.xml.soap package and it looks like you are getting the wrong version of J2EE specs. While the tutorial is working against J2EE 5 API specification, I think you have a j2ee.jar for the J2EE 1.4 specification.

Try getting the version 5 j2ee.jar, add that to your classpath, remove the older one and try again.
 
Yes, I think that's the case. Thanks for your reply!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top