Axis serialization error:Number Format Exception - java

I am developing a web application in STS. In it a webservice is to be called and the results are to be shown.I generated the web service clients from wsdl using STS itself.
I created a sample java file that sends a request to this web service and returns the results.The following is the code:
public final class Client {
static Answer answerObj;
private Client() {
}
public static Answer webCall() throws Exception {
// START SNIPPET: client
Question questionObj = new Question();
questionObj.setName("t");
questionObj.setNameStartsWith(true);
questionObj.setDistrict("kob");
questionObj.setHouseNo("0");
questionObj.setPhone("0");
questionObj.setStreet("hai");
questionObj.setStreetStartsWith(false);
//questionObj.setAccountantName("")
questionObj.setCvrNo(1);
//questionObj.setDistrict("Soendergade 2C ");
//Like this set all the values here .
/*System.getProperties().put("proxySet", "true");
System.getProperties().put("https.proxyHost", "");
System.getProperties().put("https.proxyPort",80 );*/
answerObj =nne_PortTypeProxyObj.search(questionObj, 10, 10, 0, "");
System.out.println(answerObj.getCompanyBasic().length);
return answerObj;
// END SNIPPET: client
}
}
Now my problem is that, when i call the method search in the web service, the following exception occurs:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Client
faultSubcode:
faultString: caught exception while handling request: deserialization error: java.lang.NumberFormatException: For input string: ""
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:caught exception while handling request: deserialization error: java.lang.NumberFormatException: For input string: ""
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1774)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2930)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at net.stibo.com.nne._3_1.PortTypeBindingStub.search(PortTypeBindingStub.java:1446)
at net.stibo.com.nne._3_1PortTypeProxy.search(PortTypeProxy.java:188)
at com.sapienter.jbilling.server.util.Client.webCall(Client.java:51)
at com.sapienter.jbilling.server.util.Client$webCall.call(Unknown Source)
I searched for the same in stackoverflow and found this:
multiRef in generated xml sending by WS
I think this is the problem because i tried various parameters with search method.But there is no good solution found for this. Can anyone help me?PLZZZ help....

I don't know what's the problem with the AXIS generated stubs.But I overcomed the situation by using java SAAJ library by framing request as needed by the webservice as in the link:
Working Soap client example

Related

{http://xml.apache.org/axis/}stackTrace:java.net.SocketTimeoutException: Read timed out

I used jboss 5.1
and I used soap webservice in my project.
most of time the web service works
correctly
but sometime I have this error :
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.net.SocketTimeoutException: Read timed out
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at org.apache.axis.transport.http.HTTPSender.readHeadersFromSocket(HTTPSender.java:583)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:143)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.web.service.BalanceServiceSoapBindingStub.getInfo(BalanceServiceSoapBindingStub.java:550)
at com.web.manager.impl.TestManagerImpl.newEmp(TestManagerImpl.java:893)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
this is my soap client code :
BalanceServiceServiceLocator balance = new BalanceServiceServiceLocator();
BalanceServiceSoapBindingStub service = new BalanceServiceSoapBindingStub(new URL(
balance.getBalanceServiceAddress()), balance);
EmployeeEntity employeeDetail = service.getInfo(matricule);
I think that I should increase the timeout and I try with this code :
BalanceServiceServiceLocator balance = new BalanceServiceServiceLocator();
BalanceServiceSoapBindingStub service = new BalanceServiceSoapBindingStub(new URL(
balance.getBalanceServiceAddress()), balance);
org.apache.axis.client.Stub s = service;
s.setTimeout(new Integer(1000*120));
EmployeeEntity employeeDetail = service.getInfo(matricule);
is it the best way to resolve the problem
updated :
sometimes after increasing the timeout I solved my problem
but sometimes the same error appeared again : faultString: java.net.SocketTimeoutException: Read timed out
note that soap webservice client and server is in two different network range
is it problem of network, firewall
and is it possible to make a configuration in the firewall to accept HTTP traffic,
or how can i modify my code in order to handle this exception meaning
I display in my application that I have network problem
after for example 30 second without getting the response

Unexpected subelement highLevelCategoryReq, Transaction Search

When updating our .wsdl files to the latest Yodlee SOAP API (2014_Q4), errors started being thrown in the area of the code where it wasn't before. There wasn't any change in the our code dealing with transaction searches. The error being thrown is
org.apache.axis2.databinding.ADBException: Unexpected subelement highLevelCategoryReq
Which is happening on a executeUserSearchRequest call, i.e.
Locators.transactionSearchService.executeUserSearchRequest(userContext, transactionSearchRequest)
The setting up of the searchRequest is practically the exact same as what is shown in the sample code (latest Java SDK sample code, with the folder named Aggregation12-JavaSampleApps). A snippet is shown below
val transactionSearchRange = new TransactionSearchResultRange()
transactionSearchRange.setStartNumber(startRange)
transactionSearchRange.setEndNumber(endRange)
val transactionSearchRequest = new TransactionSearchRequest()
val transactionSearchFilter = new TransactionSearchFilter
transactionSearchFilter.setTransactionSplitType(TransactionSplitType.ALL_TRANSACTION)
val itemAccountId = new ItemAccountId()
itemAccountId.setIdentifier(bankData.getItemAccountId)
transactionSearchFilter.setItemAccountId(itemAccountId)
transactionSearchRequest.setSearchFilter(transactionSearchFilter)
transactionSearchRequest.setIgnorePaymentTransactions(false)
transactionSearchRequest.setIncludeAggregatedTransactions(true)
transactionSearchRequest.setResultRange(transactionSearchRange)
transactionSearchRequest.setContainerType("all")
transactionSearchRequest.setSearchClients(TransactionSearchClients.DEFAULT_SERVICE_CLIENT)
transactionSearchRequest.setIgnoreUserInput(true)
Locators.transactionSearchService.executeUserSearchRequest(userContext, transactionSearchRequest)
Stacktrace up to what is relevant is as follows
org.apache.axis2.databinding.ADBException: Unexpected subelement highLevelCategoryReq
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2973)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:333)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.yodlee.soap.core.transactionsearch.transactionsearchservice.TransactionSearchServiceSoapBindingStub.executeUserSearchRequest(TransactionSearchServiceSoapBindingStub.java:1019)
Is this an error we are expected to catch and deal with, or is it indicative of some bigger underlying issue?
You need to use the right SOAP version end point. Since you are using 2014Q4 WSDLs , the endpoint to all the API calls should point to 2014Q4 version.
Example -
For transaction search - https://xxx.yodlee.com/yodsoap/services/TransactionSearchService_2014Q4
So please change the service version for all the URLs and it should resolve your problem.

java.lang.IllegalArgumentException

I'm less than a beginner in Java (I'm a .NET developer), but i have to fix a Java error when invoking a WebMethod through a proxy class.
From .NET, I can call it with no problems, but in Java, this is what happens:
java.lang.IllegalArgumentException
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at weblogic.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1411)
at weblogic.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1613)
at weblogic.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1174)
at weblogic.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:399)
at weblogic.apache.xerces.framework.XMLParser.parse(XMLParser.java:1147)
at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:147)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.verizon.vmw.csgw.ws.updateDOJob.v4_4.wsdl.UpdateDOJobServiceSoapBindingStub.updateDOJob(UpdateDOJobServiceSoapBindingStub.java:206)
at com.verizon.vmw.csgw.ws.updateDOJob.v4_4.wsdl.UpdateDOJobServiceProxy.updateDOJob(UpdateDOJobServiceProxy.java:50)
at rm.interfaces.wfadosnd.WfaDoSndWorker.updateDOJobComments(WfaDoSndWorker.java:1111)
at rm.interfaces.wfadosnd.WfaDoSndWorker.checkEtaAsgn(WfaDoSndWorker.java:507)
at rm.interfaces.wfadosnd.WfaDoSndWorker.resequenceDODispatches(WfaDoSndWorker.java:541)
at rm.interfaces.wfadosnd.WfaDoSndWorker.processOutboundRows(WfaDoSndWorker.java:283)
at rm.interfaces.wfadosnd.WfaDoSndWorker.run(WfaDoSndWorker.java:112)
at rm.util.WorkerThread.run(ThreadPool.java:152)
Does anyone have any idea of what could be causing this exception?
Check with Wireshark what goes over the wire and diff the .NET request with the java request.
Looks like your web application was receiving a message, and one of its fields failed verification that it was the right type (or acceptable value).
Whether that was a data issue, or a coding issue depends heavily on the data, code, and intent which are all not provided.
As you can see from the class names in the stack trace, the exception is thrown during deserialization of the webservice response.
The exception itself is pretty generic and hence carries little useful information.
Try looking at the response sent over the wire, or set an exception breakpoint in eclipse so you can inspect the stack frames the exception is thrown to get additional context. (To ease interpretation of what went wrong, you'll probably want to procure the source code of your web service stack).
look in the code for something is parsed for user input
like this Integer i = Integer.parseInt("string");
and the "string" contains none valid number

org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it

I'm getting an error when I try to generate an element that should look like
<hold/>
Using the java client code generated by Axis2.
java snippet
HoldPayment hold = new HoldPayment()
cr.setHold(hold);
but when I fire it off I get an error of WRONG_DOCUMENT_ERR. If I don't include this element in the message being fired off it works fine. anyone got any idea how to fix it?
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
at com.sun.org.apache.xerces.internal.dom.ParentNode.internalInsertBefore(ParentNode.java:352)
at com.sun.org.apache.xerces.internal.dom.ParentNode.insertBefore(ParentNode.java:284)
at com.sun.org.apache.xerces.internal.dom.NodeImpl.appendChild(NodeImpl.java:235)
at org.apache.axis.message.SOAPFaultBuilder.onEndChild(SOAPFaultBuilder.java:305)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1090)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1774)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2930)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at au.com.virginblue.www.schema._2005._02.booking_wsdl.BookingBindingStub.createReservation(BookingBindingStub.java:1803)
at com.test.GetDJBooking.main(GetDJBooking.java:215)
{http://xml.apache.org/axis/}hostname:test.com.au
org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:701)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at au.com.virginblue.www.schema._2005._02.booking_wsdl.BookingBindingStub.createReservation(BookingBindingStub.java:1803)
at com.nhh.dj.GetDJBooking.main(GetDJBooking.java:215)
Caused by: org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
at com.sun.org.apache.xerces.internal.dom.ParentNode.internalInsertBefore(ParentNode.java:352)
at com.sun.org.apache.xerces.internal.dom.ParentNode.insertBefore(ParentNode.java:284)
at com.sun.org.apache.xerces.internal.dom.NodeImpl.appendChild(NodeImpl.java:235)
at org.apache.axis.message.SOAPFaultBuilder.onEndChild(SOAPFaultBuilder.java:305)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1090)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1774)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2930)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
... 14 more
I use this implementation to add Node from one XML document to other.
Node firstDocImportedNode = firstDoc.importNode(secondDocsNode, true);
firstDocNode.appendChild(firstDocImportedNode );
See if this helps. Trick is just importing a Node to other Document, instead of directly appending.
We saw this error when send SOAP message with CXF.
org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
at org.apache.xerces.dom.ParentNode.internalInsertBefore(ParentNode.java:351)
at org.apache.xerces.dom.ParentNode.insertBefore(ParentNode.java:283)
at org.apache.xerces.dom.CoreDocumentImpl.insertBefore(CoreDocumentImpl.java:393)
at org.apache.xerces.dom.NodeImpl.appendChild(NodeImpl.java:236)
at org.jboss.ws.core.soap.SOAPDocument.appendChild(SOAPDocument.java:226)
at org.jboss.ws.core.soap.SOAPPartImpl.appendChild(SOAPPartImpl.java:300)
at org.apache.cxf.staxutils.W3CDOMStreamWriter.setChild(W3CDOMStreamWriter.java:119) [cxf-common-utilities-2.5.4.jar:2.5.4]
at org.apache.cxf.staxutils.W3CDOMStreamWriter.newChild(W3CDOMStreamWriter.java:109) [cxf-common-utilities-2.5.4.jar:2.5.4]
at org.apache.cxf.staxutils.W3CDOMStreamWriter.writeStartElement(W3CDOMStreamWriter.java:137) [cxf-common-utilities-2.5.4.jar:2.5.4]
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:122) [cxf-rt-bindings-soap-2.4.6.jar:2.4.6]
Error was in SAAJOutInterceptor that has processed before SoapOutInterceptor. Saaj implementation was from JBoss. And it create document with another classloader. This document from Saaj break SoapOutInterceptor.
We solved this problem adding dependency to our module.
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.3</version>
</dependency>
You can't copy a node from one document and paste it to another. An attempt to do so results in this type of error.
The node has to be properly imported. If I remember well, the Document class offers the right methods for this common task.
EDIT
The problem might be in the code behind the setHold method. The element has to be imported. If this is all autogenerated code, then looking for a newer version of axis could solve the problem. See my comment, where I mentioned an axis 1.3/1.4 issue.
The answer is in complete adherence to Sudheer Palyam's answer and seeks to add a bit of clarity to his answer.
In the example below, I have a Node 'node' which I have created somewhere else and is a part of different XML Document.
Secondly, I have a NodeList whose Nodes I want to append in the Node 'node' mentioned above.
So, I imported the nodes from NodeList one by one into the Document of Node 'node'.
Once a node is imported, I appended it into Node 'node'.
Document ownerDocument = node.getOwnerDocument();
for(int count = 0; count < otherDocumentNodeChildNodes.getLength(); count++)
{
Node child = otherDocumentNodeChildNodes.item(count);
Node importedNode = ownerDocument.importNode(child, true);
node.appendChild(importedNode);
}

Axis 1.4 AxisFault Premature end of file

I get this error when I use my autogenerated ServiceBindingStub.java. WebService side is working ok, so this error must be in code, but code is autogenerated, so I cannot know why it doesn't work. Some other calls work fine, but this doesn't. This call included updating, while other working calls are just fetching data from WebService.
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: Premature end of file.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Premature end of file.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
This happens when service you are connecting to does not return SOAP response, but some text or HTML. Try opening the URL in the browser or use some SOAP debugger like SOAP UI to see what is returned from the service.
I once had the same problem. In my case, I received messages with 'binary data' between tags (imagery). Axis used a fixed size buffer to read the data, once the buffer was full it just proceeded and ran out of sync.
In fact, you should be able to find the tag or part in the xml file by debugging the stub code step by step. No guarantee, that the issue will can be solved easily but it might give you a hint that the (a) stub is not generated correctly or (b) the xml file is just not well-formed or valid against the schema that has been used to generate the stub.
Good luck! (I didn't solve my issue..)
I just had (and solved) this problem, following Superfilin's answer. In the end, the problem turned out to be that I hadn't added a <beanMapping> for one of the classes I was returning in my deployment.wsdd file. Any time the response would have included that class, I'd get a completely empty message body instead.
Even we have faced the same issue. But there are some special characters in the content. We removed those special characters and it worked fine.

Categories