XmlDocumentxmlDoc=newXmlDocument();
//CreatetheDetailnode
XmlNoderootNode=xmlDoc.CreateNode(XmlNodeType.Element,
SoapException.DetailElementName.Name,
SoapException.DetailElementName.Namespace);
//BuildspecificdetailsfortheSoapException
//AddfirstchildofdetailXMLelement.
XmlNodeerrorNode=xmlDoc.CreateNode(XmlNodeType.Element,"Error",
webServiceNamespace);
//CreateandsetthevaluefortheErrorNumbernode
XmlNodeerrorNumberNode=
xmlDoc.CreateNode(XmlNodeType.Element,"ErrorNumber",
webServiceNamespace);
errorNumberNode.InnerText=errorNumber;
//CreateandsetthevaluefortheErrorMessagenode
XmlNodeerrorMessageNode=xmlDoc.CreateNode(XmlNodeType.Element,
"ErrorMessage",
webServiceNamespace);
errorMessageNode.InnerText=errorMessage;
//CreateandsetthevaluefortheErrorSourcenode
XmlNodeerrorSourceNode=
xmlDoc.CreateNode(XmlNodeType.Element,"ErrorSource",
webServiceNamespace);
errorSourceNode.InnerText=errorSource;
//AppendtheErrorchildelementnodestotherootdetailnode.
errorNode.AppendChild(errorNumberNode);
errorNode.AppendChild(errorMessageNode);
errorNode.AppendChild(errorSourceNode);
//AppendtheDetailnodetotherootnode
rootNode.AppendChild(errorNode);
//Constructtheexception
SoapExceptionsoapEx=newSoapException(errorMessage,
faultCodeLocation,uri,
rootNode);
//Raisetheexceptionbacktothecaller
returnsoapEx;
}
|