2017-07-07 6 views
1

SOAP WebサービスをテストするためにREST保証ライブラリを使用する可能性はありますか? 私はSOAP UIに一連のテストスイートを持っており、REST Assuredを使用する可能性があるかどうかを確認する必要があります。 これが可能なら誰でも提案できますか? コメントありがとうございました。SOAP WebサービスのテストにREST保証ライブラリを使用

答えて

0

REST-保証SOAPサービスをテストするための直接的なサポートはありませんが、それは手動で通常のために行うように、あなたが応答にするXPathアサーションを実行することができますなどSOAPActionContent-Typeヘッダを設定し、HTTP POSTを行うことで可能ですRESTで保証されたRESTサービス。

Karateには、SOAPの組み込みサポートがあり、XML操作も非常に簡単になるため、評価することをお勧めします。ここで

0

私は

ヘッダSOAPActionContent-Type必須ているあなたに例を示しています。

RestAssured.baseURI = "http://url"; 

です:あなたは、ウィッヒはあなたのケースでSOAPActionヘッダーで見つけることが、時にはあなたが設定する必要があり、コードの最後の「/」のURLで

import static io.restassured.RestAssured.given; 
import io.restassured.RestAssured; 
import io.restassured.path.xml.XmlPath; 
import io.restassured.response.Response; 

XmlPath xmlPath; 
Response response; 

RestAssured.baseURI = "http://url"; 
response = 
       given() 
        .request().body("xml_text").headers("SOAPAction", "findSoapAction", "Content-Type", "text/xml"). 
       when() 
        .post("/path"). 
       then() 
        .assertThat() 
         .statusCode(200).extract().response(); 
System.out.println(response.asString()); 

//next we get the xmlPath of the response 
xmlPath = response.xmlPath(); 
//and get the value of a node in the xml 
String nodeValue= xmlPath.get("fatherNode.childNode"); 
System.out.println(nodeValue); 

要素の次の部分がされて必要要求

given().request().body("xml_text") 

体O引数を()にするURLが要求

012のXMLの文字列です

"findSoapAction"は、推測すべきSOAPActionヘッダーの値を持つ文字列で、 "text/xml"はContent-Typeヘッダーとして設定する必要があります。

xmlPath.get("fatherNode.childNode"); 

ノードの値を返します。例:

<fatherNode> 
    <childNode>value of the node</childNode> 
</fatherNode> 

GET( "fatherNode.childNode") "ノードの値を" 返す

関連する問題