找到你要的答案

Q:SOAP ui giving multiple response from one request. (Trying to create Mock services)

Q:从一个请求提供多个响应的SOAP UI。(试图创建模拟服务)

I am facing a strange issue. Also I am new in soapui. I am trying to create a Mock service using WSDL. I created request as well as a response in soapui. Problem is whenever I click from the request window to get the response, one by one i am getting all the responses (I have created 2 requests and 2 responses). I googled a lot but did not get through this issue. Please help me in this. In a nutshell : "How can I select the right response based on a condition ?"

I am facing a strange issue. Also I am new in soapui. I am trying to create a Mock service using WSDL. I created request as well as a response in soapui. Problem is whenever I click from the request window to get the response, one by one i am getting all the responses (I have created 2 requests and 2 responses). I googled a lot but did not get through this issue. Please help me in this. In a nutshell : "How can I select the right response based on a condition ?"

answer1: 回答1:

I have found the answer. I wrote a script:

def alert = com.eviware.soapui.support.UISupport;
def req = new XmlSlurper().parseText(mockRequest.requestContent)

if(req=='CI'){
    alert.showInfoMessage("111111 !  "+req);
    return "CityResponse"
}else if(req=='ST'){
    alert.showInfoMessage("2222222 !  "+req);
    return "StateResponse"
}else{
    alert.showInfoMessage("333333 !  "+req);
    return "CountryResponse"
}

I have found the answer. I wrote a script:

def alert = com.eviware.soapui.support.UISupport;
def req = new XmlSlurper().parseText(mockRequest.requestContent)

if(req=='CI'){
    alert.showInfoMessage("111111 !  "+req);
    return "CityResponse"
}else if(req=='ST'){
    alert.showInfoMessage("2222222 !  "+req);
    return "StateResponse"
}else{
    alert.showInfoMessage("333333 !  "+req);
    return "CountryResponse"
}
java  soapui