1

我正在尝试在soapui 中模拟一个异步服务。我也提到过SoapUI 模拟异步服务。但是,服务客户端没有收到回调请求,因为它没有被发送到 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

请建议我如何解决这些问题:

  • 如何从soap请求中获取寻址信息并在虚拟回调请求中使用它?
  • 如何在测试用例中设置回调请求的端点地址?

提前致谢

4

1 回答 1

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)
于 2012-06-01T10:49:45.730 回答