qileilove

          blog已經(jīng)轉(zhuǎn)移至github,大家請(qǐng)?jiān)L問 http://qaseven.github.io/

          使用WebInject測試WebService

          本文通過學(xué)習(xí)WebInject官網(wǎng)教材,然后測試自己開發(fā)的WebService。
            首先,我們有一個(gè)無敵的HelloWorld服務(wù),這個(gè)服務(wù)超級(jí)簡單,相信大家都很熟悉。就不介紹了。
            然后,創(chuàng)建SOAP消息,根據(jù)我自己的經(jīng)驗(yàn),soap消息就是把webservice的WSDL文件中的輸入輸出message給soap化了。具體看一個(gè)例子:
            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>
            轉(zhuǎn)成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中內(nèi)容。
            再然后就是測試用例文件:
          <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>
          最后在執(zhí)行這個(gè)測試用例:通過GUI方式的話,在config.xml文件中指定我們的測試用例文件即可。然后在GUI界面點(diǎn)擊Run就會(huì)執(zhí)行成功。
          -------------------------------------------------------
          Test:test_google.xml-1
          WebServicesSample-GoogleSearchAPI
          Verify:"Hello,mynameispengyusong"
          PassedXMLParser(contentiswell-formed)
          PassedPositiveVerification
          PassedHTTPResponseCodeVerification(notinerrorrange)
          TESTCASEPASSED
          ResponseTime=0.015sec
          -------------------------------------------------------
          StartTime:WedOct3016:46:342013
          TotalRunTime:0.409seconds
          TestCasesRun:1
          TestCasesPassed:1
          TestCasesFailed:0
          VerificationsPassed:3
          VerificationsFailed:0
          AverageResponseTime:0.015seconds
          MaxResponseTime:0.015seconds
          MinResponseTime:0.015seconds

          posted on 2014-09-18 09:31 順其自然EVO 閱讀(226) 評(píng)論(0)  編輯  收藏 所屬分類: 測試學(xué)習(xí)專欄

          <2014年9月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 喀喇沁旗| 油尖旺区| 晋州市| 花莲市| 怀柔区| 郴州市| 威宁| 新巴尔虎左旗| 治县。| 崇左市| 宁都县| 和政县| 灯塔市| 舟山市| 鄂州市| 淄博市| 清流县| 宿松县| 通州区| 定结县| 当阳市| 泉州市| 浪卡子县| 象州县| 苏尼特右旗| 政和县| 华池县| 云浮市| 东乌珠穆沁旗| 和田县| 新巴尔虎右旗| 达日县| 集安市| 东乡县| 昆明市| 交口县| 上饶市| 沅陵县| 昭通市| 麦盖提县| 榆中县|