// Add request properties
refreshRequestProperties();
// init default properties
addProperty(new TestStepBeanProperty("Endpoint", false, testRequest, "endpoint", this, false));
addProperty(new TestStepBeanProperty("Username", false, testRequest, "username", this, true));
addProperty(new TestStepBeanProperty("Password", false, testRequest, "password", this, true));
addProperty(new TestStepBeanProperty("Domain", false, testRequest, "domain", this, false));
// init properties
addProperty(new TestStepBeanProperty("Request", false, testRequest, "requestContent", this, true) {
@Override
public String getDefaultValue() {
return createDefaultRequestContent();
}
public SchemaType getSchemaType() {
String requestContent = getTestRequest().getRequestContent();
if (XmlUtils.seemsToBeXml(requestContent)) {
try {
// first the DOM of the current request
Document dom = XmlUtils.parseXml(requestContent);
// get matching representations
for (RestRepresentation representation : getTestRequest().getRepresentations(Type.REQUEST,
getTestRequest().getMediaType())) {
// is request element same as that of representation?
if (representation.getElement().equals(XmlUtils.getQName(dom.getDocumentElement()))) {
// this is it, return its type
return representation.getSchemaType();
}
}
} catch (Throwable e) {
SoapUI.logError(e);
}
}
// found nothing.. fall back
return super.getSchemaType();
}
@Override
public QName getType() {
return getSchemaType().getName();
}
});
addProperty(new TestStepBeanProperty(WsdlTestStepWithProperties.RESPONSE_AS_XML, true, testRequest,
"responseContentAsXml", this) {
@Override
public String getDefaultValue() {
return createDefaultResponseXmlContent();
}
public SchemaType getSchemaType() {
try {
// first the DOM of the current request
Document dom = XmlUtils.parseXml(getTestRequest().getResponseContentAsXml());
// get matching representations
for (RestRepresentation representation : getTestRequest().getRepresentations(Type.RESPONSE,
getTestRequest().getResponse().getContentType())) {
// is request element same as that of representation?
if (representation.getElement().equals(XmlUtils.getQName(dom.getDocumentElement()))) {
// this is it, return its type
return representation.getSchemaType();
}
}
} catch (Exception e) {
SoapUI.logError(e);
}
// found nothing.. fall back
return super.getSchemaType();
}
@Override
public QName getType() {
return getSchemaType().getName();
}
});
addProperty(new TestStepBeanProperty("Response", true, testRequest, "responseContentAsString", this) {
@Override
public String getDefaultValue() {
return createDefaultRawResponseContent();
}
});