Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/12/2016, 10:00
ABLOCE123
 
Fecha de Ingreso: julio-2009
Mensajes: 22
Antigüedad: 14 años, 10 meses
Puntos: 0
Pregunta Excepción Personalizada WebService .NET

Hola.
Tengo un problema para obtener una excepción personalizada de un webservice de terceros. El método funciona bien, pero cuando hay una excepción, no he podido cacharla correctamente.

Me mandaron este ejemplo. Se supone que así debería funcionar. Pero no me reconoce "exampleException " como un objeto de tipo excepción.

Código:
public byte[] getexample(String user, String pass, byte[] file) { 
try { 
exampleService.getexample(user, pass, file); 
} catch (exampleException examplee) { 
examplee.printStackTrace(); System.out.println("exampleExcepcion: " + examplee.getText()); 
} catch (RemoteException Re) { 
Re.printStackTrace(); System.out.println("RemoteExcepcion: " + Re.toString()); 
} catch (Exception e) { 
e.printStackTrace(); System.out.println("Exception: " + e.toString()); 
} }

Revisé el código que se genera con la implementación del webService y encuentro esto:

Código:
 <System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0"),  _
     System.Runtime.Serialization.DataContractAttribute(Name:="exampleException", [Namespace]:="http://example.service.ejemplo.company.com"),  _
     System.SerializableAttribute()>  _
    Partial Public Class exampleException
        Inherits Object
        Implements System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged        
        <System.NonSerializedAttribute()>  _
        Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject        
        Private codField As Integer        
        Private textField As String

Le cambié "Inherits Object" a "Inherits Exception" de esta manera ya me reconoce el objeto "exampleException ". Pero no funciona, me marca el siguiente error:

"el tipo exampleException no puede ser Iserializable y tener el atributo dataContractAttribute"

No se qué me falta por hacer, o cómo implementar este tipo de excepciones.


Les agradezco de antemano por su tiempo.


Saludos...