我正在尝试在soapui中模拟异步服务。我已经提到了SoapUI mocking asynchronous services。但是,服务客户端未收到回调请求,因为它未被发送到WS-Addressing属性中指定的所需地址。
在模拟服务和模拟请求上启用WS-Addressing会导致以下错误。
ERROR:com.eviware.soapui.impl.wsdl.mock.DispatchException: java.lang.NullPointerException
com.eviware.soapui.impl.wsdl.mock.DispatchException: java.lang.NullPointerException
at com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse.execute(WsdlMockResponse.java:323)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockOperation.dispatchRequest(WsdlMockOperation.java:259)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchPostRequest(WsdlMockRunner.java:290)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner.dispatchRequest(WsdlMockRunner.java:375)
at com.eviware.soapui.monitor.JettyMockEngine$ServerHandler.handle(JettyMockEngine.java:715)
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$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at com.eviware.soapui.impl.wsdl.support.soap.SoapUtils.getHeaderElement(SoapUtils.java:146)
at com.eviware.soapui.impl.wsdl.support.wsa.WsaUtils.getHeader(WsaUtils.java:138)
at com.eviware.soapui.impl.wsdl.support.wsa.WsaUtils.createWSAddressingMockResponse(WsaUtils.java:488)
at com.eviware.soapui.impl.wsdl.support.wsa.WsaUtils.addWSAddressingMockResponse(WsaUtils.java:480)
at com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse.execute(WsdlMockResponse.java:287)
... 16 more
请建议我如何解决这些问题:
提前致谢
答案 0 :(得分:0)
soapUI在模拟异步服务中隐式支持ws-addressing。您需要从soap请求中获取详细信息并将其作为回调请求的一部分传回。以下代码解决了这个问题。
def holder = groovyUtils.getXmlHolder(mockRequest.requestContent)
def map = new com.eviware.soapui.support.types.StringToObjectMap()
holder.declareNamespace("wsa","http://www.w3.org/2005/08/addressing")
map.put("messageID", holder.getNodeValue("//wsa:MessageID/text()"))
def address = holder.getNodeValue("//wsa:ReplyTo/wsa:Address/text()")
map.put("address", java.net.URLDecoder.decode(address, "UTF-8"))
def testsuite = context.mockService.project.getTestSuiteByName("callbackBinding TestSuite")
def testcase = testsuite.getTestCaseByName("successResponse TestCase")
//get mock request teststep by type
def testrequest = (WsdlTestRequestStep)testcase.getTestStepsOfType(WsdlTestRequestStep.class).get(0)
//Set endpoint for the testcase request. Endpoint is the replyTo address sent by by the caller
testrequest.testRequest.setEndpoint(address)
testcase.run(map, false)