}
final Node p = nodes.item(0);
// build definition
final ResponseDefinition response = new ResponseDefinition();
final String textContent = p.getTextContent().trim();
final String[] responseCode = textContent.split(" ");
if (!"Response".equals(responseCode[0])) {
throw new ServiceException("Response definition should start with 'Response'");
}
// HTTP response code
response.setCode(Integer.parseInt(responseCode[1]));
// check for MIME type
String restOfLine = textContent.substring(
textContent.indexOf(response.getCode()) + responseCode[1].length());
if (restOfLine.length() > 0) {
restOfLine = restOfLine.trim();
if (restOfLine.startsWith("(")) {
restOfLine = restOfLine.substring(1);
}
if (restOfLine.endsWith(")")) {
restOfLine = restOfLine.substring(0, restOfLine.length() - 1);
}
response.getHeaders().put(CONTENT_TYPE_STRING, restOfLine);
}
return response;
}