您好,登錄后才能下訂單哦!
本文連接:http://pengyusong.blog.51cto.com/blog/4893374/1317325
本文通過學(xué)習(xí)WebInject官網(wǎng)教材,然后測試自己開發(fā)的WebService。
首先,我們有一個無敵的HelloWorld服務(wù),這個服務(wù)超級簡單,相信大家都很熟悉。就不介紹了。
然后,創(chuàng)建SOAP消息,根據(jù)我自己的經(jīng)驗,soap消息就是把webservice的WSDL文件中的輸入輸出message給soap化了。具體看一個例子:
WSDL message格式:
<wsdl:message name="sayHelloRequest"> <wsdl:part name="parameters" element="ns:sayHello"/> </wsdl:message>
sayHello元素的格式:
<xs:element name="sayHello"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="args0" nillable="true" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>
轉(zhuǎn)成soap消息格式就是:
<?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns: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)容。
再然后就是測試用例文件:
<testcases repeat="1"> <case id="1" description1="Web Services Sample - Hello World" url="http://localhost:8080/axis2/services/HelloWorld?wsdl" method="post" posttype="text/xml" postbody="file=>doGoogleSearch.xml" verifypositive="\<return>Hello, my name is pengyusong\</return>" /> </testcases>
最后在執(zhí)行這個測試用例:通過GUI方式的話,在config.xml文件中指定我們的測試用例文件即可。然后在GUI界面點(diǎn)擊Run就會執(zhí)行成功。
------------------------------------------------------- Test: test_google.xml - 1 Web Services Sample - Google Search API Verify : "Hello, my name is pengyusong" Passed XML Parser (content is well-formed) Passed Positive Verification Passed HTTP Response Code Verification (not in error range) TEST CASE PASSED Response Time = 0.015 sec ------------------------------------------------------- Start Time: Wed Oct 30 16:46:34 2013 Total Run Time: 0.409 seconds Test Cases Run: 1 Test Cases Passed: 1 Test Cases Failed: 0 Verifications Passed: 3 Verifications Failed: 0 Average Response Time: 0.015 seconds Max Response Time: 0.015 seconds Min Response Time: 0.015 seconds
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。