Sunday, 1 February 2015

Not allowed in prolog grails XML error



I have the following on a Curl command:



curl -i -H "Content-Type: text/xml" -d '<sample:WIB xmlns:sample="www.sample.com"><sample:Customer><sample:Catalog_ID>01</sample:Catalog_ID><sample:Shop_ID>01</sample:Shop_ID></sample:Customer></sample:WIB>' http://localhost:8080/app/API/


My Grails controller is:



def index() {
String xml = request.XML.toString();
def workXml = new XmlSlurper().parseText(xml)
}


I get the error when parsing I have also tried this:



def workXml = new XmlSlurper().parseText(xml).declareNamespace(sample: 'sample')


I get the same error:


This is the stack trace:



Message: Content is not allowed in prolog.
Line | Method
->> 10 | index in app.APIController$$EP3387M0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 53 | doFilter in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
| 49 | doFilter in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter
| 82 | doFilter in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . in java.lang.Thread


Any Ideas with this?


No comments:

Post a Comment