English 中文(简体)
SoapUI Groovy 方言
原标题:SoapUI Groovy Scripts

I m试图读到即将到来的要求和计划;根据请求中的一项价值,确定模拟反应。 我为此使用了以下大写。

def typeElement = mockRequest.getContentElement().execQuery("//ProductType");
def records =  new XmlParser().parseText(typeElement[0].xmlText())
if (records.text()=="15"){
    mockOperation.setDefaultResponse("Response 2");
} else {
    mockOperation.setDefaultResponse("Response 1");
}

但是,它并不发挥作用,抱怨mockRequest。 反对:

com.eviware.soapui.impl.wsdl.mock.DisupException: Failed to sent using script; java.lang.NullPointerException: 不得援引对无效物体具有追溯效力的方法

但是,我使用类似的代码,其编号为soapUI 2.0版本,并且是成功的。 我如何确定这一点?

问题回答

我知道这个问题很老了,但我昨天也遇到了同样的问题,这里我是如何用粗体字书写来发出答复的(请注意,这是我第一次使用肥皂和牛奶,因此很可能有更好的办法这样做)。

    // define request
    def request = new XmlSlurper().parseText(mockRequest.requestContent);
    def resultingResponse = "none"

    //when missing password
    def Password = request.Body.CreateUser.user.Password
    if(Password ==   ) {
        resultingResponse =  MissingPassword 
    }

    //when missing firstname
    def Firstname = request.Body.CreateUser.user.FirstName
    if(Firstname ==   ) {
        resultingResponse =  MissingFirstname 
    }

context.ResultResponse = resultingResponse

我再次赞赏这一点是老的,但上文提到的Sinnerinc的回答并没有解决原来的问题,因为他的解决方法仍然会受到全国住户调查的困扰,因为模拟调查已经失效。

我有一个相关问题,并找到了,该信建议,如果 mo服务公司从未向过申请,你点击绿三角洲,则 mo灭!





相关问题
SoapUI Groovy 方言

我试图阅读即将提出的申请,并根据请求中价值分立的3.0作出模拟反应。 我为此使用了以下大写。

Mocking Entity Context in EF4

I am using VS2010 B2 and EF4 B2 and trying to use Rhino Mocks to mock the entity context generated by EEF. var context = MockRepository.GenerateMock<SomeDBEntities>(); IObjectSet<TxMode> ...

Google Mock for iPhone development?

I have an interesting situation where I am refactoring a bunch of ObjC iPhone code to create a C++ API. I m a novice to C++ and looking into C++ mocking frameworks to augment the work I d done using ...

StrucutureMap RhinoMock Record/Playback, Example needed

I m looking for some examples on how to do the following Mock Tests using StructureMap or Unity with NUnit. I have the following code structure public interface IDAL { List<Model> Method1(...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

Elegant design of simulating a read-only object

I am currently developing an GUI to an embedded system. (I am using GUI to descripe my app opposed to interface to avoid confusion with the progamatic meaning) Context I have created a class which ...

热门标签