技术开发 频道

在 WebSphere Portlet Factory 中创建 Web Service

    (二)Schema Builder

    在 WebServiceModel 中新建一个 Schema Builder(新建方法请参考 Method builder 的创建),打开 Schema Builder 编辑器, 如图 7


图 7. Schema Builder 编辑器
 

    如图所示:

    (1) 在 Name 中输入 Schema 名称 query

    (2) 在 Schema Source Type 中选择类型为 Existing URL/File

    (3) 在 URL or Schema File Location 中,点击右边的选择按钮打开文件选择器, 如图 8


图 8. 文件选择器 
 

    选中 预先编写好 的 Schema 文件,然后点击 OK 按钮。本项目中的 Schema 文件放在了 models 目录下面。

    注意: 选择的 Schema 文件 query.xsd 定义了 Web Service 的参数及返回值的数据结构,文件内容如 清单 2 所示:


    清单 2.
               
 <?xml version="1.0" encoding="UTF-8"?>
 <xsd:schema xmlns="http://wbs.com" xmlns:xsd="http://www.w3.org
 /2001/XMLSchema" targetNamespace="http://wbs.com"
 elementFormDefault="unqualified"
 attributeFormDefault="unqualified">
  <xsd:element name="query">
   <xsd:complexType>
    <xsd:sequence>
     <xsd:element name="arguments" type="xsd:string"/>
    </xsd:sequence>
   </xsd:complexType>
  </xsd:element>
  <xsd:element name="result">
   <xsd:complexType>
    <xsd:sequence>
     <xsd:element name="value" type="xsd:string"/>
    </xsd:sequence>
   </xsd:complexType>
  </xsd:element>
 </xsd:schema>
 


    从此文件中可以看出一共定义有两个对象:query 和 result,query 对象中包含了一个 String 类型的 arguments 对象,result 对象中包含了一个 String 类型的 value 对象。

    query 对象表示 WebServiceModel 中已经定义的方法 getQueryResult 所需要的输入参数的数据结构。

    result 对象表示 WebServiceModel 中已经定义的方法 getQueryResult 所需要的返回值的数据结构。

0
相关文章