Forum Discussion
horvathv
14 years agoNew Contributor
I managed to write a script which works well (I get the WSA messageID and relatesTo fields from the recevied request and put these values into the the SOAP header of the request of an other service and call it):
I had to put this code to the AfterRequest Script of the mock service.
// get the messageID and RelatesTo from the request that received into the mock services
def reqReceived = mockResult.mockResponse.mockResult.mockRequest
def holderReqReceived = new com.eviware.soapui.support.XmlHolder( reqReceived.requestContent )
holderReqReceived.namespaces["env"] = "http://schemas.xmlsoap.org/soap/envelope/"
holderReqReceived.namespaces["wsa"] = "http://www.w3.org/2005/08/addressing"
def messageID = holderReqReceived.getNodeValue("/env:Envelope/env:Header/wsa:MessageID")
def relatesTo = holderReqReceived.getNodeValue("/env:Envelope/env:Header/wsa:RelatesTo")
log.info "### messageID:$messageID / relatesTo:$relatesTo"
// set the messageID
def projectSend = mockResult.mockResponse.mockOperation.mockService.project.workspace.projects['MYBPELPROJECT']
def reqSend = projectSend.interfaces["BPELBinding"].operations["OPERATION"].getRequestByName("Auto Request 1")
def holderReqSend = new com.eviware.soapui.support.XmlHolder( reqSend.requestContent )
holderReqSend.namespaces["soapenv"] = "http://schemas.xmlsoap.org/soap/envelope/"
holderReqSend.namespaces["wsa"] = "http://www.w3.org/2005/08/addressing"
holderReqSend["/soapenv:Envelope/soapenv:Header/wsa:MessageID"] = messageID
holderReqSend["/soapenv:Envelope/soapenv:Header/wsa:RelatesTo"] = relatesTo
holderReqSend.updateProperty()
reqSend.setRequestContent(holderReqSend.getPrettyXml())
sleep(1000)
log.info "### I am going to call the service"
reqSend.submit(new com.eviware.soapui.impl.wsdl.WsdlSubmitContext( ), false)
I had to put this code to the AfterRequest Script of the mock service.