继承自soapException [英] Inherit from soapException

查看:94
本文介绍了继承自soapException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在尝试为Asp.net应用程序创建自定义异常层次结构。


我的一些例外情况应该来自soapException like


MyCustomWebServiceException:soapException

{

blabla

}


任何人都有som指导方针吗?正常规则实现了三个默认构造函数当然是dosnt计数,因为他们并没有给b $ b兴奋。


Google给出了这个主题我没什么。


希望有人能让我振作起来:)


Reagards

Anders,DK

Hi

Im trying to create a custom Exception Hierachy for an Asp.net application.

Some of my exceptions should iherit from soapException like

MyCustomWebServiceException : soapException
{
blabla
}

Anyone have som guidelines for this? The normal rule of emplementing the
three default constructors of course dosnt count, since he they doesnt
excitst.

Google gives my nothing in this subject.

Hope someone can cheer me up :)

Reagards
Anders, DK

推荐答案

示例:

MyCustomWebServiceException:soapException

{

私人字符串_MyCustomProperty;

公共字符串MyCustomProperty

{

get

{

返回_MyCustomProperty;

}

}

public MyCustomWebServiceException(字符串消息,

XmlQualifiedName code ,string CustomParameter)

:base(字符串消息,XmlQualifiedName代码)

{

_MyCustomProperty = CustomParameter;

}

}


-

HTH,


Kevin Spencer

Microsoft MVP

..N et developer
http://www.takempis.com

Big Things由

很多小东西组成。


" Flare" < pl*@askforit.com>在消息中写道

新闻:好的************* @ TK2MSFTNGP11.phx.gbl ...
Example:
MyCustomWebServiceException : soapException
{
private string _MyCustomProperty;
public string MyCustomProperty
{
get
{
return _MyCustomProperty;
}
}
public MyCustomWebServiceException(string message,
XmlQualifiedName code, string CustomParameter)
: base(string message, XmlQualifiedName code)
{
_MyCustomProperty = CustomParameter;
}
}

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Flare" <pl*@askforit.com> wrote in message
news:OK*************@TK2MSFTNGP11.phx.gbl...

<我试图为Asp.net
应用程序创建一个自定义Exception Hierachy。
我的一些异常应该来自soapException,例如

MyCustomWebServiceException:soapException
{
blabla
}

任何人都有som指导方针吗?实现三个默认构造函数的正常规则当然是dosnt计数,因为他们并没有激动人心。

Google在这个主题上没有给我任何意义。

Reards:
Anders,DK
Hi

Im trying to create a custom Exception Hierachy for an Asp.net application.
Some of my exceptions should iherit from soapException like

MyCustomWebServiceException : soapException
{
blabla
}

Anyone have som guidelines for this? The normal rule of emplementing the
three default constructors of course dosnt count, since he they doesnt
excitst.

Google gives my nothing in this subject.

Hope someone can cheer me up :)

Reagards
Anders, DK



Thx :)


但是。当我提出MyCustomWebServiceException时,我遇到了问题。我不能抓住

我的异常作为MyCustomWebServiceException,只有soapException。这就是一个很大的问题,因为我在客户端的错误信息看起来像这样。


----->在DANSIH SORRY但不重要。

Elsam.Turabs.ClassLibraries.TurabsException.Turabs WebServiceException:

计算错误---> System.DivideByZeroException:计算错误。在

WebServiceExp.Service1.HelloWorld()in

c:\inetpub \wwwroot \webserviceexp \service1.asmx.cs:第58行--- Slut p ?

staksporing af indre undtagelser --- at WebServiceExp.Service1.HelloWorld()

in c:\inetpub\wwwroot\webserviceexp\service1.asmx。 cs:第66行

------>


我的留言计算错误除了很多垃圾邮件之外。


所以最后的问题:为什么我不能抓住我的自定义SoapException?


WS:

---------------

[WebMethod]

public void HelloWorld()

{

尝试

{

int y = 0;

int t = 1 / y;

}

catch(System.DivideByZeroException DivideExp)

{

TurabsWebServiceException TurDBExp = new

TurabsWebServiceException(" Calculation

error",System.Web.Services.Protocols.SoapException .ServerFaultCode,DivideExp

);


throw(TurDBExp); //向客户Rethrow

}


客户:

----------

Exp.Service1 a = new WSExp.Service1();


尝试

{

a.HelloWorld ();

}

catch(System.Web.Services.Protocols.SoapException et)

{

Label1.Text = et.Message;

}

Thx :)

But. When i trow MyCustomWebServiceException i have problems. I cant catch
my exception as MyCustomWebServiceException, only soapException. And thats a
big problem, since My error message at the client look somthing like this.

-----> IN DANSIH SORRY BUT NOT IMPORTANT.
Elsam.Turabs.ClassLibraries.TurabsException.Turabs WebServiceException:
Calculation error---> System.DivideByZeroException: Calculation error. at
WebServiceExp.Service1.HelloWorld() in
c:\inetpub\wwwroot\webserviceexp\service1.asmx.cs: line 58 --- Slut p?
staksporing af indre undtagelser --- at WebServiceExp.Service1.HelloWorld()
in c:\inetpub\wwwroot\webserviceexp\service1.asmx.cs: line 66
------>

My Message "Calculation error" is in the message besides lots og junk.

So final qusiton: Why can''t i catch my custom SoapException?

The WS:
---------------
[WebMethod]
public void HelloWorld()
{
try
{
int y = 0;
int t = 1 / y ;
}
catch(System.DivideByZeroException DivideExp)
{
TurabsWebServiceException TurDBExp = new
TurabsWebServiceException("Calculation
error",System.Web.Services.Protocols.SoapException .ServerFaultCode,DivideExp
);

throw(TurDBExp); //Rethrow to client
}

The client:
----------
Exp.Service1 a = new WSExp.Service1();

try
{
a.HelloWorld();
}
catch(System.Web.Services.Protocols.SoapException et)
{
Label1.Text = et.Message;
}



您只能捕获抛出的异常。如果你创建一个Custom

异常类,你的应用程序将不得不抛出它。例如,您的应用程序可能会抓住SoapException,使用它来创建Custom

异常类的实例,然后抛出它。我不确定你究竟要用这一切来做什么,所以我只能告诉你。


-

HTH,


Kevin Spencer

Microsoft MVP

..Net Developer
http://www.takempis.com

Big事情由很多小事组成。


Flare < pl*@askforit.com>在消息中写道

news:e1 ************** @ TK2MSFTNGP10.phx.gbl ...
You can only catch the Exception that was thrown. If you create a Custom
Exception class, your app will have to throw it. For example, your app might
catch the SoapException, use that to create an instance of your Custom
Exception class, and then throw that. I''m not sure what exactly you''re
trying to do with all this, so that'' about all I can tell you.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Flare" <pl*@askforit.com> wrote in message
news:e1**************@TK2MSFTNGP10.phx.gbl...
Thx:)

但是。当我提出MyCustomWebServiceException时,我遇到了问题。我无法捕获我的异常作为MyCustomWebServiceException,只有soapException。这就是
一个大问题,因为我在客户端的错误信息看起来像这样。

----->在DANSIH SORRY但不重要。
Elsam.Turabs.ClassLibraries.TurabsException.Turabs WebServiceException:
计算错误---> System.DivideByZeroException:计算错误。在
WebServiceExp.Service1.HelloWorld()中,在c:\inetpub \ www.root \webserviceexp \service1.asmx.cs:第58行--- Slut p?
staksporing af indre undtagelser --- at
WebServiceExp.Service1.HelloWorld()in c:\inetpub\wwwroot\webserviceexp\service1.asmx.cs:line 66
------> ;

我的消息计算错误除了很多垃圾之外的消息。

所以最后的问题:为什么我不能抓住我的自定义SoapException?

WS:
---- -----------
[WebMethod]
public void HelloWorld()
{
尝试
{y / 0} ;
int t = 1 / y;
}
catch(System.DivideByZeroException DivideExp)
{
TurabsWebServiceException TurDBExp = new
TurabsWebServiceException(" Calculation

error",System.Web.Services.Protocols.SoapException .ServerFaultCode,DivideExp);

throw(TurDBExp); //向客户转发
}

客户:
----------
Exp.Service1 a = new WSExp.Service1() ;

尝试
一个.HelloWorld();
}
catch(System.Web.Services.Protocols.SoapException et)
{
Label1.Text = et.Message;
}
Thx :)

But. When i trow MyCustomWebServiceException i have problems. I cant catch
my exception as MyCustomWebServiceException, only soapException. And thats a big problem, since My error message at the client look somthing like this.

-----> IN DANSIH SORRY BUT NOT IMPORTANT.
Elsam.Turabs.ClassLibraries.TurabsException.Turabs WebServiceException:
Calculation error---> System.DivideByZeroException: Calculation error. at
WebServiceExp.Service1.HelloWorld() in
c:\inetpub\wwwroot\webserviceexp\service1.asmx.cs: line 58 --- Slut p?
staksporing af indre undtagelser --- at WebServiceExp.Service1.HelloWorld() in c:\inetpub\wwwroot\webserviceexp\service1.asmx.cs: line 66
------>

My Message "Calculation error" is in the message besides lots og junk.

So final qusiton: Why can''t i catch my custom SoapException?

The WS:
---------------
[WebMethod]
public void HelloWorld()
{
try
{
int y = 0;
int t = 1 / y ;
}
catch(System.DivideByZeroException DivideExp)
{
TurabsWebServiceException TurDBExp = new
TurabsWebServiceException("Calculation
error",System.Web.Services.Protocols.SoapException .ServerFaultCode,DivideExp );

throw(TurDBExp); //Rethrow to client
}

The client:
----------
Exp.Service1 a = new WSExp.Service1();

try
{
a.HelloWorld();
}
catch(System.Web.Services.Protocols.SoapException et)
{
Label1.Text = et.Message;
}



这篇关于继承自soapException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆