ASP .NET
  • Introduction
  • Chapter1.MVC 5
    • 1.1.The Complete ASP.NET MVC 5 Course
      • 1.0. Deploy .NET project to IIS
      • 1.1.Getting started
        • 1.1.1.MVC Architectural
        • 1.1.2.Setting up the development environment
        • 1.1.3.Create MVC APP
        • 1.1.4.Add a new Model, Controller, View
      • 1.2.ASP.NET MVC Fundamentals
        • 1.2.1.Action
        • 1.2.2.Route
        • 1.2.3.Pass data to views
        • 1.2.4.ViewModel
        • 1.2.5.View
      • 1.3.Working with data
        • 1.3.1.Entity framework
        • 1.3.2.Database First v.s. Code First
        • 1.3.3.Code-first Migrations
        • 1.3.4.Seeding the database
        • 1.3.5.Overriding conventions
        • 1.3.6.Query objects
      • 1.4.Building Forms
        • 1.4.1.The Markup (labelFor, textbox, checkbox)
        • 1.4.2.Labels
        • 1.4.3.Drop down list
        • 1.4.4.Model binding and save data
        • 1.4.5.Edit form
      • 1.5.Implement validation
        • 1.5.1.Adding validation
        • 1.5.2.Data annotation
        • 1.5.3.Client side validation
        • 1.5.4.Anti-forgery Tokens
      • 1.6. Building RESTful API
        • 1.6.1. What is Web API?
        • 1.6.2. RESTful convetion
        • 1.6.3. Building a API and testing
        • 1.6.4. Data Transfer Object
        • 1.6.5. Use camel annotation
        • 1.6.6. Use IHttpActionResult
      • 1.7.Client-side Development
        • 1.7.1.Calling an API using jQuery
        • 1.7.2.Bootbox plug-in
        • 1.7.3.DataTable plug-in using AJAX source
        • 1.7.4.Returning Hierarchical Data
      • 1.8.Authentication and Authorization
        • 1.8.1.The problem
        • 1.8.2.Authentication options
        • 1.8.3.Restricting Access
        • 1.8.4.Seeding Users and Roles
        • 1.8.5.Working with Roles
        • 1.8.6.Adding Profile Data
        • 1.8.7.OAuth
        • 1.8.8.Social Logins
      • 1.9.Performance Optimization
        • 1.9.1.Overview
        • 1.9.2.Data Tier
        • 1.9.3.Glimpse
        • 1.9.4.Output Cache
        • 1.9.5.Data Cache
        • 1.9.6.Async
        • 1.9.7.Disabling Session
        • 1.9.8.Client Tier
      • 1.10.Building a Feature End-to-End Systematically
        • 1.10.1.Domain Modelling
        • 1.10.2.Adding Auto-completion
        • 1.10.3.Updating the DOM
        • 1.10.4.Implementing Client-side Validation
      • 1.11.Deployment
        • 1.11.1.Deploying the application
        • 1.11.2.Deploying the database
        • 1.11.3.Build configurations
        • 1.11.4.Application settings
        • 1.11.5.Custom Error Pages
        • 1.11.6.Logging Unhandled Exceptions
      • 1.12.Approved collection server
        • 1.12.1.Overview
        • 1.12.2.測試上傳審批資料
        • 1.12.3.取得Token的方式
        • 1.12.4.測試取得審批資料, Log資料
        • 1.12.5.將API接口綁定到雲之家審批
    • 1.2.Skilltree MVC 實戰營筆記
      • 1.2.1..NET MVC overview and razor view
      • 1.2.2.Controller, Model, Entity framework, service
      • 1.2.3.HTML helper, Extension method, Validation
      • 1.2.4.Security, ActionFilter, ActionResult
      • 1.2.5.DataType, Templates
  • Chapter2.SignalR
    • 2.1.Getting started
      • 2.1.1.Install signalR on VS2013
    • 2.2.Basic of SignalR
      • 2.2.1.Chat App Ovierview
      • 2.2.2.Creating a hub
      • 2.2.3.Connecting to the hub
      • 2.2.4.Create A server method and calling from client
      • 2.2.5.Passing parameters to server method from client
      • 2.2.6.Creating a client method and calling from server
    • 2.3. Exploring the class hub and group chat
      • 2.3.1.OnConnected, OnDisconnected
      • 2.3.2. ContextObject and JSON serialization
      • 2.3.3. Clients Object's Methods
      • 2.3.4. Add Or Remove Connection From Groups
      • 2.3.5. Sending Messages To Different Groups
  • Chapter3.REST API Design, Development & Management
    • 3.1.Evolution of RESTful services
      • 3.1.1.Evolution of REST/JSON API
      • 3.1.2.Introduction to RESTful API
      • 3.1.3.Private, Public and Partner API
    • 3.2.REST API Architectural Constraints
      • 3.2.1.Introduction to REST Architecture Constraints
      • 3.2.2.Client-Server
      • 3.2.3.Uniform Interface
      • 3.2.4.Statelessness
      • 3.2.5.Caching
      • 3.2.6.Layered system
      • 3.2.7.Code on demand
      • 3.2.8.Richardson Maturity Model for REST API
    • 3.3.Designing REST API
      • 3.3.1.API value chain
      • 3.3.2.Practices for Resource Names, Actions & Associations
      • 3.3.3.Implementing REST API CRUD operations
      • 3.3.4.Walkthrough: Creating a Vacations API in Node JS
      • 3.3.5.REST API Error Handling Practices
      • 3.3.6.Walkthrough: Implementation of error handling for POST API
      • 3.3.7.Versioning the API
      • 3.3.8.API Caching (1 of 2) Concepts & Design decisions
      • 3.3.9.API Caching (2 of 2) Concepts & Design decisions
      • 3.3.10. Demo - API Caching using Cache-Control Directives
      • 3.3.11.Building support for Partial Responses
    • 3.4.REST API Security
      • 3.4.1.REST API Security - Introduction
      • 3.4.2.Securing API with Basic Authentication
      • 3.4.3.Securing API with Tokens & JWT
      • 3.4.4.Securing API with API Key & Secret
      • 3.4.5.API Authorization using OAuth2.0
        • 3.4.5.1.Authorization scope grant (Refresh token grant)
        • 3.4.5.2.Client credentials grant
        • 3.4.5.3.Implicit Grant
        • 3.4.5.4.Resource owner credentials grant
      • 3.4.6.API Security - Functional Attack
    • 3.5.REST API Specifications using Swagger 2.0 / OAI
      • 3.5.1.Requirements Analysis Process & Intro to REST Specifications
      • 3.5.2.Swagger/OAI Specifications Walkthrough
      • 3.5.3.Swagger/OAI Specifications, Part 1 of 3
      • 3.5.4.Swagger/OAI Specifications, Part 2 of 3
      • 3.5.5.Swagger/OAI Specifications, Part 3 of 3
    • 3.6.API management
      • 3.6.1.Introduction to API Management
      • 3.6.2.API Lifecycle & Developer Productivity
      • 3.6.3.API Developer Portal
      • 3.6.4.API Security management
      • 3.6.5.API Traffic Management
      • 3.6.6.API Analytics
      • 3.6.7.API Product and API Monetization
    • 3.7.Summary
  • Chapter4.REST API/Web Services testing with SoapUI
    • 4.1.Web Service Basics
      • 4.1.1.Introduction of WSDL
      • 4.1.2.Introduction of SOAP
      • 4.1.3.Introduction to XML
    • 4.2.SoapUI Basics
      • 4.2.1.Create TestSuite and TestCase
      • 4.2.2.Exporting and Importing project into workspace
      • 4.2.3.Running mock service- might come handy when your actual service is down
    • 4.3.Assertion
      • 4.3.1.XPath Expression
      • 4.3.2.Writing first assertion
      • 4.3.3.Assertions - Compliance,Status & Standards
      • 4.3.4.XQuery assertion
      • 4.3.5.Handling CDATA - using XPath and Groovy
    • 4.4.Working with Properties
      • 4.4.1.Property expansion
Powered by GitBook
On this page
  • 1. CDATA
  • 2.Parsing CDATA
  • 3.Parsing CDATA by using Groovy

Was this helpful?

  1. Chapter4.REST API/Web Services testing with SoapUI
  2. 4.3.Assertion

4.3.5.Handling CDATA - using XPath and Groovy

Previous4.3.4.XQuery assertionNext4.4.Working with Properties

Last updated 5 years ago

Was this helpful?

1. CDATA

  • 嵌在XML裡面的區塊, 可以是XML, 也可以是其他資訊

  • 搭配Groovy來parsing

  • 無法用一般的方式parsing

2.Parsing CDATA

  • 1.Add Assertion-> Property Content -> XPath Match

  • 2.點選Declare

  • 3.填上路徑

    • e.g.,

          <getAirportInformationByAirportCodeResponse xmlns="http://www.webserviceX.NET">
               <getAirportInformationByAirportCodeResult><![CDATA[<?xml version="1.0" encoding="UTF-8"?><NewDataSet>
                <Table>
                  <AirportCode>LHR</AirportCode>
                  <CityOrAirportName>LONDON HEATHROW</CityOrAirportName>
                  <Country>Great Britain (UK)</Country>
                  <CountryAbbrviation>GB</CountryAbbrviation>
                  <CountryCode>493</CountryCode>
                  <GMTOffset>0</GMTOffset>
                  <RunwayLengthFeet>12802</RunwayLengthFeet>
                  <RunwayElevationFeet>80</RunwayElevationFeet>
                  <LatitudeDegree>51</LatitudeDegree>
                  <LatitudeMinute>28</LatitudeMinute>
                  <LatitudeSecond>0</LatitudeSecond>
                  <LatitudeNpeerS>N</LatitudeNpeerS>
                  <LongitudeDegree>0</LongitudeDegree>
                  <LongitudeMinute>27</Longitude
                  <LongitudeSeconds>0</LongitudeSeconds>
                  <LongitudeEperW>W</LongitudeEperW>
                </Table>
    • 應填入

3.Parsing CDATA by using Groovy

  • 3.編輯script

      1. context.expand放的字串順序為: Test step名稱#Response#declare...;//ns1

      1. 用groovy.util.XmlSlurper來parse出想要得到的key

      import groovy.util.XmlSlurper
      //1. Extract CDATA from the response
      
      //declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/';
      //declare namespace ns1='http://www.webserviceX.NET';
      //ns1:getAirportInformationByAirportCodeResponse/ns1:getAirportInformationByAirportCodeResult/text()
      def responseText = context.expand('${getAirportInformationByAirportCode#Response#declare namespace       ns1=\'http://www.webserviceX.NET\';//ns1:getAirportInformationByAirportCodeResponse/ns1:getAirportInformationByAirportCodeResult/text()}')
      log.info responseText
      
      XmlSlurper xmlSlurper = new XmlSlurper()
      
      def xmlData = xmlSlurper.parseText(responseText)
      
      log.info xmlData
      
      //2. I want to Assert airportCode == 'LHR'
      log.info xmlData.Table[0].AirportCode
      
      String airportCode= xmlData.Table[0].AirportCode
      
      assert airportCode == 'LHR'
      
      log.info 'Assering done'

1.Add Assertion-> Property Content -> XPath Match

2.重新命名Test step: 改為getAirportInformationByAirportCode