Results 1 to 3 of 3
- 10-26-2010, 11:07 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
Migrating Java SOAP app. Help please
Hello :)
I'm having a problem moving an existing application to a new server. On the new server, the app is returning nulls when reading any part of the SOAP response. This app uses the standard java SOAP lib, javax.xml.soap.
All the non-standard jars have been copied/updated. As far as I can tell, the software differences between the old and new servers are OS, JVM version, and Tomcat version.
New Server
Tomcat Version : Apache Tomcat/6.0.26
JVM Version : 1.6.0_20-b02
JVM Vendor : Sun Microsystems Inc.
OS Name : Windows Server 2008 R2
OS Version : 6.1
OS Architecture : amd64
Old Server
Tomcat Version : Apache Tomcat/5.5.9
JVM Version : 1.5.0_11-b03
JVM Vendor : Sun Microsystems Inc.
OS Name : Windows 2003
OS Version : 5.2
OS Architecture : x86
The SOAP response is recevied by both and looks the same. It is written to the logs on both servers.
The java code itself, throws no error when accessing the SOAP response. It even writes the log with the full response text but when trying to read the response elements it only returns a null.Java Code:<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <CheckResponse xmlns="http://www.xxxxxx.zzz/"> <CheckResult>SUCCESS</CheckResult> </CheckResponse> </soap:Body> </soap:Envelope>
Here's the section of code in question :
The output generated by that code for the old server is :Java Code:// Build XML and pass it all to JA's web service. Trap any errors in strStatus...WG try { // Init. SOAPConnectionFactory SOAPConnFac = SOAPConnectionFactory.newInstance(); SOAPFactory SOAPFac = SOAPFactory.newInstance(); MessageFactory MessageFac = MessageFactory.newInstance(); // Create the SOAP Connection. SOAPConnection SOAPConn = SOAPConnFac.createConnection(); // Build the SOAP request message. SOAPMessage SOAPRequestMsg = MessageFac.createMessage(); // Add info to the MIME header for .NET compatibility, (JA's service is written in .NET). MimeHeaders hd = SOAPRequestMsg.getMimeHeaders(); hd.addHeader("SOAPAction", "http://www.companyserver.zzz/companySOAP"); // Remove the SOAP message header, it is not needed in this case. SOAPHeader SOAPRequestHeader = SOAPRequestMsg.getSOAPHeader(); SOAPRequestHeader.detachNode(); // Build the SOAP body element companySOAP. SOAPBody SOAPRequestBody = SOAPRequestMsg.getSOAPBody(); javax.xml.soap.Name nameRequestBody = SOAPFac.createName("companySOAP", "", "http://www.companyserver.zzz/"); SOAPBodyElement sbeRequestBodyEle = SOAPRequestBody.addBodyElement(nameRequestBody); // Add all child elements to the companySOAP element. SOAPElement seNameNode = sbeRequestBodyEle.addChildElement("Name"); seNameNode.addChildElement("FirstName").addTextNode(strDBFName); seNameNode.addChildElement("MiddleInitial").addTextNode((strDBMName != null) ? ((strDBMName.length()>1) ? strDBMName.substring(0,1) : strDBMName) : ""); seNameNode.addChildElement("LastName").addTextNode(strDBLName); sbeRequestBodyEle.addChildElement("SSN").addTextNode(strDBSSN); SOAPElement seDOBNode = sbeRequestBodyEle.addChildElement("DOB"); seDOBNode.addChildElement("Y").addTextNode(strDBBirthDate.split("/")[2]); seDOBNode.addChildElement("M").addTextNode(strDBBirthDate.split("/")[0]); seDOBNode.addChildElement("D").addTextNode(strDBBirthDate.split("/")[1]); // Debug code, writes xml to the log file. SOAPRequestMsg.writeTo(System.out); System.out.println(""); URL urlWebService = new URL ("http://SOAPServer/companySOAP/"); // Send the SOAP request message and get back the SOAP response message. SOAPMessage SOAPResponseMsg = SOAPConn.call(SOAPRequestMsg, urlWebService); SOAPConn.close(); // Debug code, writes xml to the log file. SOAPResponseMsg.writeTo(System.out); System.out.println(""); // Pull out the SOAP response body. SOAPBody SOAPResponseBody = SOAPResponseMsg.getSOAPBody(); // Check for SOAP faults. if (SOAPResponseBody.hasFault()) { intProgressMarker = 101; // Tracking information. SOAPFault newFault = SOAPResponseBody.getFault(); strStatus = "SOAP FAULT:<br>"; strStatus += "<br>code = " + newFault.getFaultCodeAsName(); strStatus += "<br>message = " + newFault.getFaultString(); strStatus += "<br>actor = " + newFault.getFaultActor()+"<br>"; boolOK = false; } else { // Pull the CheckResponse element out of the SOAP response body. javax.xml.soap.Name nameResponseBody = SOAPFac.createName("CheckResponse", "", "http://www.companyserver.zzz/"); Iterator iterElement = SOAPResponseBody.getChildElements(nameResponseBody); if (iterElement.hasNext()){ SOAPBodyElement sbeResponseBodyEle = (SOAPBodyElement) iterElement.next(); // Check for success or failure. String strResultMsg = ((sbeResponseBodyEle.getValue() == null) ? sbeResponseBodyEle.toString() : sbeResponseBodyEle.getValue()); strStatus = "<br>Check response came back from SOAPServer as * " + strResultMsg + " *<br>"; // Note : using compareTo() will not work here due to invisible non-blank chars in strResultMsg. boolOK = (strResultMsg.trim().toUpperCase().indexOf("SUCCESS") > 0); intProgressMarker = (boolOK) ? 1 : 100; // Tracking information. } // End if (iterElement.hasNext()) } // End if (SOAPResponseBody.hasFault()) } catch(Exception e) { intProgressMarker = 102; // Tracking information. strStatus = "Error : "+((e.getMessage() != null) ? e.getMessage() : e.toString()); boolOK = false; // Extra debug info. StackTraceElement[] aryStackTrace = e.getStackTrace(); for (int intElement = 0; intElement < aryStackTrace.length; intElement++) { strStatus += aryStackTrace[intElement].toString(); strStatus += "<br>"; } if (strStatus.length() > 500) { strStatus = strStatus.substring(0, 499); } } // End try
Check response came back from SOAPServer as * SUCCESS *
On the new server it is :
Check response came back from SOAPServer as * null *
Any ideas/fixes for this issue?
Thanks for the help folks.
- 10-30-2010, 06:32 PM #2
if these soap cllases come from the built-into java API, it's quite possible these have changed a lot from 1.5 to 1.6. Recently I had an issue with JaxRPC that was upgraded to a different version between an update release, like between 1.6.0_16 and 1.6.0_17.
if possible try to run things on java 1.5 on the new machine to see if the errors go away ?
- 11-01-2010, 09:20 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
got it now
I found what it was. In short, I was over confident about what was loading and what was not. That'll teach me.
Long answer, axis 1.5 was on the old system but was not suppose to be used because it was not in the endorsed folder and hence should not have loaded at all thanks to changes in java (1.4 I think) that introduced jar endorsing. The combination of JVM 1.5 and Tomcat 5.5 did allow the load of the jaxrpc.jar from axis (which I was, wrongly, so sure would not be allowed). While the javax.xml.soap lib (saaj.jar) was not loaded, it looks like the change in rpc was enough to break things when the axis based jar was no longer loaded.
The new server behaved as I expected it to in relation to endorsed jars while the old server did not.
Well, lesson learned. Assume nothing! Ok, may you can assume a few things so you don't end up like Descartes - staring at wax in your hand and contemplating the existence or both wax and hand. Thanks and later all.
Similar Threads
-
How can we create the soap in java and get the response in soap by java
By javastuden in forum New To JavaReplies: 1Last Post: 10-25-2010, 06:54 PM -
Java GForge SOAP Interface 0.0.8
By JavaBean in forum Java SoftwareReplies: 0Last Post: 07-13-2007, 05:33 PM -
Java GForge SOAP Interface 0.0.7
By JavaBean in forum Java SoftwareReplies: 0Last Post: 07-09-2007, 04:41 PM -
Java GForge SOAP Interface 0.0.4
By JavaBean in forum Java SoftwareReplies: 0Last Post: 06-26-2007, 09:50 PM -
Java GForge SOAP Interface 0.0.3
By levent in forum Java SoftwareReplies: 0Last Post: 06-19-2007, 05:15 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks