1

I am trying to mock an asynchronous service in soapui. I have referred SoapUI mocking asynchronous services for the same. However the callback request is not received by the service client as it is not being sent to required address specified in WS-Addressing properties.

Enabling the WS-Addressing on the mock service and and mock request results in following error.

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

Please suggest how can I resole these issues :

  • How to get the addressing information from soap request and use it in dummy callback request ?
  • How to set the endpoint address for the callback request in the test case ?

Thanks in advance

Community
  • 1
  • 1
Pradeep
  • 81
  • 8

1 Answers1

0

soapUI does not support ws-addressing implicitly in mock asynchronous service. You need to get the details from the soap request and pass it back as part of callback request. Following code solves the issue.

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)
Pradeep
  • 81
  • 8