使用WebInject测试WebService

发表于:2014-9-17 11:27

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:somebody_else    来源:51Testing软件测试网采编

  本文通过学习WebInject官网教材,然后测试自己开发的WebService。
  首先,我们有一个无敌的HelloWorld服务,这个服务超级简单,相信大家都很熟悉。就不介绍了。
  然后,创建SOAP消息,根据我自己的经验,soap消息就是把webservice的WSDL文件中的输入输出message给soap化了。具体看一个例子:
  WSDLmessage格式:
  <wsdl:messagename="sayHelloRequest">
  <wsdl:partname="parameters"element="ns:sayHello"/>
  </wsdl:message>
  sayHello元素的格式:
  <xs:elementname="sayHello">
  <xs:complexType>
  <xs:sequence>
  <xs:elementminOccurs="0"name="args0"nillable="true"type="xs:string"/>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  转成soap消息格式就是:
<?xmlversion='1.0'encoding='UTF-8'?>
<soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:q0="http://ws.apache.org/axis2"xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<q0:sayHello>
<args0>pengyusong</args0>
</q0:sayHello>
</soapenv:Body>
</soapenv:Envelope>
  可以看到soap消息就是把message中的part解析为soap中的body中内容。
  再然后就是测试用例文件:
<testcasesrepeat="1">
<case
id="1"
description1="WebServicesSample-HelloWorld"
url="http://localhost:8080/axis2/services/HelloWorld?wsdl"
method="post"
posttype="text/xml"
postbody="file=>doGoogleSearch.xml"
verifypositive="\<return>Hello,mynameispengyusong\</return>"
/>
</testcases>
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号