/// <summary> /// Gets a custom exception that wraps the SOAP exception thrown /// by the server. /// </summary> /// <param name="ex">SOAPException that was thrown by the server.</param> /// <returns>A custom exception object that wraps the SOAP exception. /// </returns> protected override Exception GetCustomException(SoapException ex) { string defaultNs = GetDefaultNamespace(); if (!string.IsNullOrEmpty(defaultNs)) { // Extract the ApiExceptionFault node. XmlElement faultNode = GetFaultNode(ex, defaultNs, "ApiExceptionFault"); if (faultNode != null) { try { DfpApiException dfpException = new DfpApiException( SerializationUtilities.DeserializeFromXmlTextCustomRootNs( faultNode.OuterXml, Assembly.GetExecutingAssembly().GetType( this.GetType().Namespace + ".ApiException"), defaultNs, "ApiExceptionFault"), ex.Message, ex); return(dfpException); } catch (Exception) { // deserialization failed, but we can safely ignore it. } } } return(new DfpApiException(null, ex.Message, ex)); }
/// <summary> /// Gets a custom exception that wraps the SOAP exception thrown /// by the server. /// </summary> /// <param name="ex">SOAPException that was thrown by the server.</param> /// <returns>A custom exception object that wraps the SOAP exception. /// </returns> protected override Exception GetCustomException(SoapException ex) { string defaultNs = GetDefaultNamespace(); if (!string.IsNullOrEmpty(defaultNs)) { // Extract the ApiExceptionFault node. XmlElement faultNode = GetFaultNode(ex, defaultNs, "ApiExceptionFault"); if (faultNode != null) { try { DfpApiException dfpException = new DfpApiException( SerializationUtilities.DeserializeFromXmlTextCustomRootNs( faultNode.OuterXml, Assembly.GetExecutingAssembly().GetType( this.GetType().Namespace + ".ApiException"), defaultNs, "ApiExceptionFault"), ex.Message, ex); return dfpException; } catch (Exception) { // deserialization failed, but we can safely ignore it. } } } return new DfpApiException(null, ex.Message, ex); }