我正在尝试向Wiremock中设置的模拟pos发送请求。这是下面intellij中的请求:
{
"request": {
"method": "POST",
"url": "/egateway/simphonyposapiweb.asmx",
"headers": {
"SOAPAction": {
"equalTo": "\"http://micros-hosting.com/EGateway/CalculateTransactionTotalsEx\""
}
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "text/xml"
},
"bodyFileName": "CalculateTransactionTotalsExResponse.xml"
}
}
我在邮递员中发布了一个请求。见下文:
http://localhost:8089/internal/v1/totals
我可以从控制台看到我的请求确实到达了pos。我可以看到消息
2020-03-06 13:53:38,550信息[http-nio-8089-exec-2] ApiRequestInterceptor:[POST] / internal / v1 / totals已成功通过身份验证。
在终端中,当我运行tail -f wiremock.log
Matched response definition:
{
"status" : 200,
"bodyFileName" : "CalculateTransactionTotalsExResponse.xml",
"headers" : {
"Content-Type" : "text/xml"
}
}
Response:
HTTP/1.1 200
Content-Type: [text/xml]
Matched-Stub-Id: [734e39bb-98dd-4488-bf57-f9b8b5cca7a2]
2020-03-06 13:53:38.856 Outgoing bytes: HTTP/1.1 200 OK
Content-Type: text/xml
Matched-Stub-Id: 734e39bb-98dd-4488-bf57-f9b8b5cca7a2
Content-Encoding: gzip
Vary: Accept-Encoding, User-Agent
Transfer-Encoding: chunked
Server: Jetty(9.2.z-SNAPSHOT)
但是我收到一条异常消息
A
2020-03-06 13:53:38.857 Problem decoding network traffic
java.nio.charset.MalformedInputException: Input length = 1
at java.nio.charset.CoderResult.throwException(CoderResult.java:281)
at java.nio.charset.CharsetDecoder.decode(CharsetDecoder.java:816)
at com.github.tomakehurst.wiremock.http.trafficlistener.ConsoleNotifyingWiremockNetworkTrafficListener.outgoing(ConsoleNotifyingWiremockNetworkTrafficListener.java:49)
at com.github.tomakehurst.wiremock.jetty9.JettyHttpServer$NetworkTrafficListenerAdapter.outgoing(JettyHttpServer.java:471)
at wiremock.org.eclipse.jetty.io.NetworkTrafficSelectChannelEndPoint.notifyOutgoing(NetworkTrafficSelectChannelEndPoint.java:144)
at wiremock.org.eclipse.jetty.io.NetworkTrafficSelectChannelEndPoint.flush(NetworkTrafficSelectChannelEndPoint.java:65)
at wiremock.org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:408)
at wiremock.org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:302)
at wiremock.org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:129)
at wiremock.org.eclipse.jetty.server.HttpConnection$SendCallback.process(HttpConnection.java:721)
at wiremock.org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:246)
at wiremock.org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:208)
at wiremock.org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:472)
at wiremock.org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:756)
at wiremock.org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:794)
at wiremock.org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:155)
at wiremock.org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:148)
at wiremock.org.eclipse.jetty.server.HttpOutput.flush(HttpOutput.java:250)
at java.util.zip.DeflaterOutputStream.flush(DeflaterOutputStream.java:282)
at wiremock.org.eclipse.jetty.servlets.gzip.AbstractCompressedStream.flush(AbstractCompressedStream.java:129)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.writeAndTranslateExceptions(WireMockHandlerDispatchingServlet.java:234)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.applyResponse(WireMockHandlerDispatchingServlet.java:223)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet$ServletHttpResponder.respondTo(WireMockHandlerDispatchingServlet.java:183)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet$ServletHttpResponder.respondSync(WireMockHandlerDispatchingServlet.java:150)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet$ServletHttpResponder.respond(WireMockHandlerDispatchingServlet.java:144)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:90)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:120)
at wiremock.javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at wiremock.org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at wiremock.org.eclipse.jetty.servlets.gzip.GzipHandler.handle(GzipHandler.java:479)
at wiremock.org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at wiremock.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at wiremock.org.eclipse.jetty.server.Server.handle(Server.java:499)
at wiremock.org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at wiremock.org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258)
at wiremock.org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:748)
2020-03-06 13:53:38.863 Outgoing bytes:
292
我很困惑我的请求是否有效?为什么我会收到此错误?
感谢您的帮助!