dlsunf

原文地址:SOAPUI测试REST项目(六)——REST服务和WADL

↑↑↑ 原文用的SoapUI,2018-3-19时,这个软件已经更名为ReadyAPI(集成了SoapUI),因此下文中我重新截屏。

本文介绍如何从零开始通过WebService的REST服务URL建立SoapUI Project,查看Request/Response,及WADL。

更多关于SoapUI的软件使用方法,请参阅其他文档。

1. 新建Workspace,空Project

菜单 → Workspace → New Workspace,新建一个工作区。

菜单 → New Empty Project,新建一个空项目。

2. 添加REST服务、源和方法

首先创建一个新的REST服务在项目中。 在导航器中右键单击您的项目并选择New URI的REST服务:

指定以下URL Google地图API在新的REST服务对话框:( http://maps.googleapis.com/maps/api/geocode/xml?address=Rio&sensor=false )

系统会自动填充创建服务所需的资源和方法。 得到以下的导航树:

3. 添加REST服务、源和方法

提交Request1请求左上角绿色三角,你将获得Response:

执行前:

执行后:

4. 查看/导出WADL文件

焦点在 REST Service上,选择 WADL Content 窗口:

 

(可选)如需导出,在REST Service上右键 → Export WADL :

生成如下WADL文件:

<?xml version="1.0" encoding="UTF-8"?>

<application xmlns="http://wadl.dev.java.net/2009/02">
  <doc xml:lang="en" title="http://maps.googleapis.com"/>
  <resources base="http://maps.googleapis.com">
    <resource path="maps/api/geocode/xml" id="Xml">
      <doc xml:lang="en" title="Xml"/>
      <param name="address" default="Rio" type="xs:string" required="false" style="query" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
      <param name="sensor" default="false" type="xs:string" required="false" style="query" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
      <method name="GET" id="Xml">
        <doc xml:lang="en" title="Xml"/>
        <request>
          <param default="Rio" name="address" type="xs:string" required="false" style="query" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
          <param default="false" name="sensor" type="xs:string" required="false" style="query" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
        </request>
        <response status="200">
          <representation mediaType="application/xml; charset=UTF-8"/>
        </response>
      </method>
    </resource>
  </resources>
</application>

 

分类:

技术点:

相关文章:

  • 2021-11-29
  • 2021-11-19
  • 2021-11-19
  • 2021-08-08
  • 2021-05-24
  • 2021-11-19
  • 2021-11-19
  • 2021-11-19
猜你喜欢
  • 2021-12-13
  • 2021-11-19
  • 2021-03-31
  • 2021-10-16
  • 2021-10-26
  • 2021-09-22
  • 2021-11-21
相关资源
相似解决方案