jqGrid soap error – 由以下命令引起:com.ctc.wstx.exc.WstxUnexpectedCharException:prolog中的意外字符’_’(代码95); 预期'<'
我实现了简单的SOAP Web服务。 使用soapUI成功传输请求和响应XML。
==请求XML
==响应XML
aupres aaa 45 husband hwa5383 bbb 40 wife julian ccc 15 son
我尝试用jqGrid脚本调用响应soap XML,如下所示
jQuery SOAP test
$(document).ready(function(){ var soapMessage = " " + " " + " " + " " + " " + "" var $Grid = $("#grid"); $Grid.jqGrid({ mtype: "post", url: "CallMemberBean", datatype: "xml", datastr: soapMessage, processData: false, xmlReader : { root : "return" }, colNames : [ 'id', 'password', 'age', 'name' ], colModel : [ { name : 'id', width:40, align:'center', xmlmap:'id'}, { name : 'passwd', width:80, align:'left', xmlmap:'passwd'}, { name : 'age', width:80, align:'left', xmlmap:'age'}, { name : 'name', width:80, align:'right', xmlmap:'name' } ], pager : '#pager', rowNum : '10', loadComplete : onloadComplete, loadError : onloadError, gridComplete : ongridComplete }); function onloadComplete(data) { console.log(data) } function onloadError(jqXHR, textStatus, errorThrown) { console.log(jqXHR) console.log(errorThrown) console.log(textStatus) } });
此jqGrid客户端代码抛出以下错误
20:45:52,568 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default task-45) Interceptor for {http://www.aaa.com}CallMemberBeanService has thrown exception, unwinding now: org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader. at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:259) at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:65) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:241) at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:97) at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:131) at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:88) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:286) at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:206) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final] at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:136) at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:140) [jbossws-spi-2.3.1.Final.jar:2.3.1.Final] at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final] at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final] at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final] at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final] at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final] at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final] at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final] at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final] at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) [undertow-core-1.1.8.Final.jar:1.1.8.Final] at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final] at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.8.Final.jar:1.1.8.Final] at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final] at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.8.Final.jar:1.1.8.Final] at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final] at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final] at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final] at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final] at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:248) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final] at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:77) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final] at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:167) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final] at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199) [undertow-core-1.1.8.Final.jar:1.1.8.Final] at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:761) [undertow-core-1.1.8.Final.jar:1.1.8.Final] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_65] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_65] at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_65] Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '_' (code 95) in prolog; expected '<' at [row,col {unknown-source}]: [1,1] at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639) at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2052) at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134) at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1157) at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:161) ... 39 more
您发布的错误消息看起来像服务器端错误 。 您使用datatype: "xml"
,数据将从url: "CallMemberBean"
加载。 要使用datastr: soapMessage
作为网格的输入数据而不是向url
发出请求,您需要使用datatype: "xmlstring"
。
如果soapMessage
包含Request XML ,那么您应该使用postData
参数而不是datastr
参数:
postData: soapMessage
如果postData
参数的类型是字符串,就像你的情况一样,那么postData
的值postData
替换标准参数,它通常会发送jqGrid。 您可能应该另外添加ajaxGridOptions: { contentType: "text/xml; charset=utf-8" }
选项。
将自定义格式化数据发送到服务器的另一种方法是使用serializeGridData
回调函数。 返回回调的数据将用作底层jQuery.ajax请求使用的数据。 它允许您构建包含一些动态选项(当前页码,页面大小等)的SOAP请求:
serializeGridData: function (postdata) { return soapMessage; // can be build from postdata dynamically }