Announcement Announcement Module
Collapse
No announcement yet.
NAMESPACE_ERR using WebServiceTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NAMESPACE_ERR using WebServiceTemplate

    I recently upgraded my Tomcat version from 5.0-jwsdp to Tomcat 5.5, and I suddenly started receiving errors like this one using JDOM to build XML and AbstractJDOMPayloadEndpoint:

    Code:
    org.springframework.ws.soap.client.SoapFaultClientException: org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
    	at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:36)
    	at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:528)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:411)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:357)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:305)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:296)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:286)
    	at com.choruscall.ws.test.form.FormLoadClient.simpleSendAndReceive(FormLoadClient.java:34)
    	at com.choruscall.ws.test.form.FormLoadClient.loadForm(FormLoadClient.java:55)
    	at com.choruscall.ws.test.form.FormLoadUpdateTest.main(FormLoadUpdateTest.java:21)
    org.jdom.input.JDOMParseException: Error on line -1: Premature end of file.
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:468)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:770)
    	at com.choruscall.ws.test.form.FormLoadClient.loadForm(FormLoadClient.java:60)
    	at com.choruscall.ws.test.form.FormLoadUpdateTest.main(FormLoadUpdateTest.java:21)
    Caused by: org.xml.sax.SAXParseException: Premature end of file.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
    	... 3 more
    Caused by: org.xml.sax.SAXParseException: Premature end of file.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:770)
    	at com.choruscall.ws.test.form.FormLoadClient.loadForm(FormLoadClient.java:60)
    	at com.choruscall.ws.test.form.FormLoadUpdateTest.main(FormLoadUpdateTest.java:21)
    Caused by: org.xml.sax.SAXParseException: Premature end of file.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    	at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
    	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:770)
    	at com.choruscall.ws.test.form.FormLoadClient.loadForm(FormLoadClient.java:60)
    	at com.choruscall.ws.test.form.FormLoadUpdateTest.main(FormLoadUpdateTest.java:21)
    In all of my spring-ws tests.

    My client code looks like this:

    Code:
    public class FormLoadClient {
        private final WebServiceTemplate webServiceTemplate = new WebServiceTemplate();   
        private String message;
        
        public void setDefaultUri(String defaultUri) {      
            webServiceTemplate.setDefaultUri(defaultUri);        
        }
        
        //send to the configured default URI
        private StringResult simpleSendAndReceive() {
            StreamSource source = new StreamSource(new StringReader(message));
            StringResult result = new StringResult();
            try {
                webServiceTemplate.sendSourceAndReceiveToResult(source,result);
            }
            catch(Exception e)  {            
                e.printStackTrace();
            }
            return result;
        }   
        
        public FormTbl loadForm(Long id) {
            
            
            Element formLoadRequest = new Element("FormLoadRequest");
            formLoadRequest.setNamespace(Namespace.getNamespace(("http://test.choruscall.com/schemas/")));
            formLoadRequest.addContent(new Element("Id").addContent(id.toString()));
            
            org.jdom.Document document = new org.jdom.Document(formLoadRequest);                
            
            XMLOutputter outputter = new XMLOutputter();
            
            message = outputter.outputString(document);        
            StringResult result = simpleSendAndReceive();        
            
            ...
    
        }
    And my endpoint:

    Code:
    public class FormLoadRequestEndpoint extends AbstractJDomPayloadEndpoint{
    	
    	private final FormService formService;	
        private final Logger logger;
    	
    	public FormLoadRequestEndpoint(FormService formService, String logger) {		
    		this.formService = formService;	
            this.logger = Logger.getLogger(logger);
    	}
    	
    	protected Element invokeInternal(Element formLoadRequest) throws Exception {       
                     
                if(logger.isInfoEnabled()) {                           
                    XMLOutputter outputter = new XMLOutputter();
                    logger.info("invokeInternal(): Received FormLoadRequest: " + 
                            outputter.outputString(formLoadRequest));
                }
    		    Element idElement = formLoadRequest.getChild("Id");
    		    long id = -1;
            
    		    if(idElement != null) {
    		        id = new Long(idElement.getTextTrim());
    		    }
                
    		    XMLObject form = formService.loadForm(id);       
                Element test = form.getXML();                          
    
                org.jdom.Document document = new org.jdom.Document(test);                
                
                XMLOutputter outputter = new XMLOutputter();           
                
                System.out.println(outputter.outputString(document)); 
                
    		    return test;       
    	}
    }
    The XML my endpoint is making looks ok to me. It's a fairly large message, but I will post it upon request if it will help (I've also changed my client code since this version, but it is untested in Tomcat 5.0 and gives me the same DOMException as this anyway). The strangest thing to me is that the code is the same as it was before my Tomcat upgrade, and since then I've been getting these exceptions.

    Anyone have any ideas?

    John

  • #2
    Any solutions regarding the given problem?

    I'm facing a similar problem I don't know how to fix it. Did you manage to find a solution?

    OP

    Comment


    • #3
      Were you able to fix this problem?
      Thanks,
      --Narasimha

      Comment

      Working...
      X