-
-
Save qadatta/15124fbc34e3cbc15eb1e8fbafd4bef3 to your computer and use it in GitHub Desktop.
Using RestAssured to do a SOAP web service request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test.ra; | |
import static com.jayway.restassured.RestAssured.*; | |
import static com.jayway.restassured.path.xml.XmlPath.*; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class SOAPDictionary { | |
public static void main(String[] args) { | |
// http://services.aonaware.com/DictService/DictService.asmx?op=Define | |
// http://services.aonaware.com/DictService/DictService.asmx?wsdl | |
baseURI = "http://services.aonaware.com"; | |
port = 80; | |
String word = "hand"; | |
String myEnvelope = "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + | |
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">" + | |
"<soap12:Body>" + | |
"<Define xmlns=\"http://services.aonaware.com/webservices/\">" + | |
"<word>" + word + "</word>" + | |
"</Define>" + | |
"</soap12:Body>" + | |
"</soap12:Envelope>"; | |
Map<String, String> authhdrs = new HashMap<String, String>(); | |
authhdrs.put("SOAPAction", "Define"); | |
//authhdrs.put("Content-Length", Integer.toString( myEnvelope.length() ) ); | |
String xml = given().request().headers(authhdrs) | |
.contentType("application/soap+xml; charset=UTF-8;").body( myEnvelope ) | |
.when().post( "/DictService/DictService.asmx" ).andReturn().asString(); | |
String prettyXML = with(xml).prettyPrint(); | |
System.out.println( prettyXML ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment