我的问题是: 我在SoapUI Mock中以UTF-8-BOM获得Soap请求。 SoapUI无法处理UTF-8-BOM。如果我尝试处理UTF-8-BOM请求,我会收到错误“org.apache.xmlbeans.XmlException:error:prolog中不允许使用内容。” 我想用OnRequest Script替换请求中的第一个字节。
我在“OnRequest Script”中编写了这段代码来替换我请求的第一个字节。
def mockRequestContent
try {
mockRequestContent = mockRequest.getRequestContent()
mockRequestContent = replace(mockRequestContent) // method returns substring(1)
mockRequest.setRequestContent(mockRequestContent)
} catch (Exception e) {
log.info(e)
}
但是当我向Mock发送回复时,我没有在“脚本日志”选项卡中收到错误,但是我在标签“错误日志”中看到错误(见下文)。
设置请求内容的正确方法是什么?
“错误日志”选项卡上的错误
Mon Mar 06 19:02:26 MSK 2017:ERROR:org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script25.groovy: 97: unexpected token: catch @ line 97, column 4.
} catch {Exception e} {
^
org.codehaus.groovy.syntax.SyntaxException: unexpected token: catch @ line 97, column 4.
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:140)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)
at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:162)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613)
at groovy.lang.GroovyShell.parse(GroovyShell.java:625)
at groovy.lang.GroovyShell.parse(GroovyShell.java:652)
at groovy.lang.GroovyShell.parse(GroovyShell.java:643)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:136)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:87)
at com.eviware.soapui.impl.wsdl.mock.dispatch.ScriptMockOperationDispatcher.selectMockResponse(ScriptMockOperationDispatcher.java:87)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockOperation.dispatchRequest(WsdlMockOperation.java:199)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchPostRequest(WsdlMockDispatcher.java:219)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchRequest(WsdlMockDispatcher.java:114)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:142)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:604)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Script25.groovy:97:4: unexpected token: catch
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.tryBlock(GroovyRecognizer.java:9344)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1130)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.blockBody(GroovyRecognizer.java:1495)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.openBlock(GroovyRecognizer.java:8315)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.variableDefinitions(GroovyRecognizer.java:2364)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.declaration(GroovyRecognizer.java:2140)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1208)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:757)
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:131)
... 33 more
1 error
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script25.groovy: 97: unexpected token: catch @ line 97, column 4.
} catch {Exception e} {
^
org.codehaus.groovy.syntax.SyntaxException: unexpected token: catch @ line 97, column 4.
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:140)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)
at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:162)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613)
at groovy.lang.GroovyShell.parse(GroovyShell.java:625)
at groovy.lang.GroovyShell.parse(GroovyShell.java:652)
at groovy.lang.GroovyShell.parse(GroovyShell.java:643)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:136)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:87)
at com.eviware.soapui.impl.wsdl.mock.dispatch.ScriptMockOperationDispatcher.selectMockResponse(ScriptMockOperationDispatcher.java:87)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockOperation.dispatchRequest(WsdlMockOperation.java:199)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchPostRequest(WsdlMockDispatcher.java:219)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchRequest(WsdlMockDispatcher.java:114)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:142)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:604)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Script25.groovy:97:4: unexpected token: catch
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.tryBlock(GroovyRecognizer.java:9344)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1130)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.blockBody(GroovyRecognizer.java:1495)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.openBlock(GroovyRecognizer.java:8315)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.variableDefinitions(GroovyRecognizer.java:2364)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.declaration(GroovyRecognizer.java:2140)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1208)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:757)
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:131)
... 33 more
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:309)
at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:149)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:119)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:131)
at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:359)
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:142)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)
at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:162)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613)
at groovy.lang.GroovyShell.parse(GroovyShell.java:625)
at groovy.lang.GroovyShell.parse(GroovyShell.java:652)
at groovy.lang.GroovyShell.parse(GroovyShell.java:643)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:136)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:87)
at com.eviware.soapui.impl.wsdl.mock.dispatch.ScriptMockOperationDispatcher.selectMockResponse(ScriptMockOperationDispatcher.java:87)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockOperation.dispatchRequest(WsdlMockOperation.java:199)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchPostRequest(WsdlMockDispatcher.java:219)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchRequest(WsdlMockDispatcher.java:114)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:142)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:604)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Mon Mar 06 19:02:26 MSK 2017:ERROR:com.eviware.soapui.impl.wsdl.mock.DispatchException: Failed to dispatch using script; org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script25.groovy: 97: unexpected token: catch @ line 97, column 4.
} catch {Exception e} {
^
org.codehaus.groovy.syntax.SyntaxException: unexpected token: catch @ line 97, column 4.
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:140)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)
at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:162)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613)
at groovy.lang.GroovyShell.parse(GroovyShell.java:625)
at groovy.lang.GroovyShell.parse(GroovyShell.java:652)
at groovy.lang.GroovyShell.parse(GroovyShell.java:643)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:136)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:87)
at com.eviware.soapui.impl.wsdl.mock.dispatch.ScriptMockOperationDispatcher.selectMockResponse(ScriptMockOperationDispatcher.java:87)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockOperation.dispatchRequest(WsdlMockOperation.java:199)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchPostRequest(WsdlMockDispatcher.java:219)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchRequest(WsdlMockDispatcher.java:114)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:142)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:604)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Script25.groovy:97:4: unexpected token: catch
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.tryBlock(GroovyRecognizer.java:9344)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1130)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.blockBody(GroovyRecognizer.java:1495)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.openBlock(GroovyRecognizer.java:8315)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.variableDefinitions(GroovyRecognizer.java:2364)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.declaration(GroovyRecognizer.java:2140)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1208)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:757)
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:131)
... 33 more
1 error
com.eviware.soapui.impl.wsdl.mock.DispatchException: Failed to dispatch using script; org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script25.groovy: 97: unexpected token: catch @ line 97, column 4.
} catch {Exception e} {
^
org.codehaus.groovy.syntax.SyntaxException: unexpected token: catch @ line 97, column 4.
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:140)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)
at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:162)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613)
at groovy.lang.GroovyShell.parse(GroovyShell.java:625)
at groovy.lang.GroovyShell.parse(GroovyShell.java:652)
at groovy.lang.GroovyShell.parse(GroovyShell.java:643)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:136)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:87)
at com.eviware.soapui.impl.wsdl.mock.dispatch.ScriptMockOperationDispatcher.selectMockResponse(ScriptMockOperationDispatcher.java:87)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockOperation.dispatchRequest(WsdlMockOperation.java:199)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchPostRequest(WsdlMockDispatcher.java:219)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchRequest(WsdlMockDispatcher.java:114)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:142)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:604)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Script25.groovy:97:4: unexpected token: catch
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.tryBlock(GroovyRecognizer.java:9344)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1130)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.blockBody(GroovyRecognizer.java:1495)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.openBlock(GroovyRecognizer.java:8315)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.variableDefinitions(GroovyRecognizer.java:2364)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.declaration(GroovyRecognizer.java:2140)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1208)
at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:757)
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:131)
... 33 more
1 error
at com.eviware.soapui.impl.wsdl.mock.dispatch.ScriptMockOperationDispatcher.selectMockResponse(ScriptMockOperationDispatcher.java:91)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockOperation.dispatchRequest(WsdlMockOperation.java:199)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchPostRequest(WsdlMockDispatcher.java:219)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockDispatcher.dispatchRequest(WsdlMockDispatcher.java:114)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:142)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:604)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
答案 0 :(得分:0)
如果我在MockService上使用您的代码作为OnRequest script
(首先添加log.info
来跟踪请求):
def mockRequestContent
try {
mockRequestContent = mockRequest.getRequestContent()
// log request
log.info mockRequestContent
mockRequestContent = mockRequestContent.substring(1)
mockRequest.setRequestContent(mockRequestContent)
} catch (Exception e) {
log.info(e)
}
作为模拟操作的Dispach: SCRIPT
,我再次记录由于之前substring(1)
而导致的OnRequest script
响应:
log.info mockRequest.getRequestContent()
return 'DefaultMockResponseName'
如果我启动Mock服务并将其作为示例XML发送(第一个<
用于删除第一个字符的示例):
<<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Header/>
<Body>
<test>
</test>
</Body>
</Envelope>
然后在Script log
中,我看到第一个字符被移除的预期输出:
Tue Mar 07 11:36:22 CET 2017:INFO:<<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><test></test></Body></Envelope>
Tue Mar 07 11:36:22 CET 2017:INFO:<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><test></test></Body></Envelope>
如果它可以帮助我尝试使用 SOAPUI版本5.2.1