Visual Basic.NET - Excepción Personalizada WebService .NET

 
Vista:

Excepción Personalizada WebService .NET

Publicado por Abdiel Lopez (1 intervención) el 08/12/2016 17:34:36
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.

1
2
3
4
5
6
7
8
9
10
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:

1
2
3
4
5
6
7
8
9
10
11
<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...
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 481
Bronce
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Excepción Personalizada WebService .NET

Publicado por Miguel (476 intervenciones) el 08/12/2016 22:47:19
Quítale la implementación (interfaz) "ISerializabe" a tu clase Excepcion
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar