Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOAP Response message parsing error java.lang.ClassCastException: oracle.j2ee.ws.saaj.soap.TextImpl cannot be cast to javax.xml.soap.SOAPElement #76

Open
Tomas-Kraus opened this issue Sep 24, 2014 · 4 comments

Comments

@Tomas-Kraus
Copy link
Member

We are getting error java.lang.ClassCastException: oracle.j2ee.ws.saaj.soap.TextImpl cannot be cast to javax.xml.soap.SOAPElement while parsing SOAP response message.

Below code is for your reference.

<%@page import="javax.xml.soap.,javax.xml.parsers."%>

SOAPConnectionFactory CF = SOAPConnectionFactory.newInstance();
SOAPConnection soapC = CF.createConnection();
MessageFactory MF = MessageFactory.newInstance();
SOAPMessage soapMsg = MF.createMessage();
SOAPPart soapP = soapMsg.getSOAPPart();
SOAPEnvelope soapE = soapP.getEnvelope();

try

{ soapE.addNamespaceDeclaration("urn","urn:sap-com:document:sap:rfc:functions"); SOAPBody soapB = soapE.getBody(); SOAPElement soapEle = soapB.addChildElement("Z_RAP_BAPI_PO_GETDETAILS","urn"); SOAPElement soapEle1 = soapEle.addChildElement("PURCHASEORDER"); soapEle1.addTextNode("4100528320"); MimeHeaders MH = soapMsg.getMimeHeaders(); MH.addHeader("SOAPAction","http://sap.com/xi/WebService/soap1.1"); soapMsg.saveChanges(); System.out.println("Request SOAP message"); soapMsg.writeTo(System.out); SOAPMessage soapResponse = soapC.call(soapMsg,"http://sappidev..."); System.out.println("Response SOAP message"); soapResponse.writeTo(System.out); SOAPElement ele = (SOAPElement)(soapResponse.getSOAPBody().getChildElements().next()); out.println(ele.getValue()); }

catch(Exception e)

{ out.println("::::::::Exception::::::::::::::"+e); }

soapC.close();

Quick response will be useful.

Environment

Oracle 10g application server

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Reported by priyadarsini

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Was assigned to gagordon

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
This issue was imported from java.net JIRA SAAJ-76

@Tomas-Kraus
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants