Java 如何在soapUI中获取webservice响应的值?

Java 如何在soapUI中获取webservice响应的值?,java,web-services,soapui,Java,Web Services,Soapui,我在soapUI中有两个步骤。我想对第二个请求自动使用第一个响应中返回的值 我可以使用${FirstStep#response}引用整个第一个响应。 但如何继续 假设响应如下,我想提取tagKey的值: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <LoginResponse xmlns="http://schemas/WebServices"&

我在
soapUI
中有两个步骤。我想对第二个请求自动使用第一个响应中返回的值

我可以使用
${FirstStep#response}
引用整个第一个响应。 但如何继续

假设响应如下,我想提取tag
Key
的值:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <LoginResponse xmlns="http://schemas/WebServices">
         <Key>asdasdasd</Key>
      </LoginResponse>
   </s:Body>
</s:Envelope>

阿斯达斯达斯德

您可以使用属性扩展,如下所示:

${FirstStep#Response#//*:Key}

您可以通读一下。

您可以使用属性扩展,如下所示:

${FirstStep#Response#//*:Key}

您可以通读一下。

您可以使用属性扩展,如下所示:

${FirstStep#Response#//*:Key}

您可以通读一下。

您可以使用属性扩展,如下所示:

${FirstStep#Response#//*:Key}
请通读一下。

有两种方法:
1.使用上下文引用

e.g `context.expand( '${RestTestStep#Response//xpathToDataNeeded}')`
  • 您可以获得整个响应并使用
    XmlSlurper
    解析它
  • def responseXml=testRunner.testCase.testSteps[“StepName”].testRequest.response.getResponseContent();
    def xmlSlurperObj=new XmlSlurper().parseText(responseXml);
    def xmlSlurperObj=new XmlSlurper().parseText(xml).declareNamespace(s:)http://schemas.xmlsoap.org/soap/envelope/");
    log.info xmlSlurperObj.Body.LoginResponse.Key.text();
    
    非常好的学习链接有两种方法:
    1.使用上下文引用

    e.g `context.expand( '${RestTestStep#Response//xpathToDataNeeded}')`
    
  • 您可以获得整个响应并使用
    XmlSlurper
    解析它
  • def responseXml=testRunner.testCase.testSteps[“StepName”].testRequest.response.getResponseContent();
    def xmlSlurperObj=new XmlSlurper().parseText(responseXml);
    def xmlSlurperObj=new XmlSlurper().parseText(xml).declareNamespace(s:)http://schemas.xmlsoap.org/soap/envelope/");
    log.info xmlSlurperObj.Body.LoginResponse.Key.text();
    
    非常好的学习链接有两种方法:
    1.使用上下文引用

    e.g `context.expand( '${RestTestStep#Response//xpathToDataNeeded}')`
    
  • 您可以获得整个响应并使用
    XmlSlurper
    解析它
  • def responseXml=testRunner.testCase.testSteps[“StepName”].testRequest.response.getResponseContent();
    def xmlSlurperObj=new XmlSlurper().parseText(responseXml);
    def xmlSlurperObj=new XmlSlurper().parseText(xml).declareNamespace(s:)http://schemas.xmlsoap.org/soap/envelope/");
    log.info xmlSlurperObj.Body.LoginResponse.Key.text();
    
    非常好的学习链接有两种方法:
    1.使用上下文引用

    e.g `context.expand( '${RestTestStep#Response//xpathToDataNeeded}')`
    
  • 您可以获得整个响应并使用
    XmlSlurper
    解析它
  • def responseXml=testRunner.testCase.testSteps[“StepName”].testRequest.response.getResponseContent();
    def xmlSlurperObj=new XmlSlurper().parseText(responseXml);
    def xmlSlurperObj=new XmlSlurper().parseText(xml).declareNamespace(s:)http://schemas.xmlsoap.org/soap/envelope/");
    log.info xmlSlurperObj.Body.LoginResponse.Key.text();
    
    很好的学习链接