}
throw ex;
}
// Create Result
CheckNamespaceAvailabilityResponse result = null;
// Deserialize Response
InputStream responseContent = httpResponse.getEntity().getContent();
result = new CheckNamespaceAvailabilityResponse();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));
Element entryElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://www.w3.org/2005/Atom", "entry");
if (entryElement != null) {
Element contentElement = XmlUtility.getElementByTagNameNS(entryElement, "http://www.w3.org/2005/Atom", "content");
if (contentElement != null) {
Element namespaceAvailabilityElement = XmlUtility.getElementByTagNameNS(contentElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "NamespaceAvailability");
if (namespaceAvailabilityElement != null) {
Element resultElement = XmlUtility.getElementByTagNameNS(namespaceAvailabilityElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "Result");
if (resultElement != null) {
boolean resultInstance;
resultInstance = DatatypeConverter.parseBoolean(resultElement.getTextContent().toLowerCase());
result.setIsAvailable(resultInstance);
}
Element reasonDetailElement = XmlUtility.getElementByTagNameNS(namespaceAvailabilityElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "ReasonDetail");
if (reasonDetailElement != null) {
String reasonDetailInstance;
reasonDetailInstance = reasonDetailElement.getTextContent();
result.setReasonDetails(reasonDetailInstance);
}
}
}
}
result.setStatusCode(statusCode);
if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
}
if (shouldTrace) {
CloudTracing.exit(invocationId, result);
}