Connecting Tech Pros Worldwide Forums | Help | Site Map

Catching errors in webservices

phlakie
Guest
 
Posts: n/a
#1: Nov 23 '05
I made a call to a stored procedure in a web method. The stored procedure
either returns an error or an integer. How do I catch this error in the web
method? Thanks.

Hammad Rajjoub
Guest
 
Posts: n/a
#2: Nov 23 '05

re: Catching errors in webservices


Hello,

You should use Exception handling to cater this scenario.

On a side not i would suggest you not to write your business logic (stored
proc calls etc) in ur web method. Rather use web methods as facade over your
business logic.

regards,
"phlakie" wrote:
[color=blue]
> I made a call to a stored procedure in a web method. The stored procedure
> either returns an error or an integer. How do I catch this error in the web
> method? Thanks.[/color]
phlakie
Guest
 
Posts: n/a
#3: Nov 23 '05

re: Catching errors in webservices


Thanks so much for your help. Taking up your side note. Can you explain
better what you mean using web methods as facade over my business logic. I'm
new to both web services and enterprise application programming. Thanx.

"Hammad Rajjoub" wrote:
[color=blue]
> Hello,
>
> You should use Exception handling to cater this scenario.
>
> On a side not i would suggest you not to write your business logic (stored
> proc calls etc) in ur web method. Rather use web methods as facade over your
> business logic.
>
> regards,
> "phlakie" wrote:
>[color=green]
> > I made a call to a stored procedure in a web method. The stored procedure
> > either returns an error or an integer. How do I catch this error in the web
> > method? Thanks.[/color][/color]
Steve
Guest
 
Posts: n/a
#4: Nov 23 '05

re: Catching errors in webservices


I believe what Hammad means is that you create a class library for example,
with all of your business logic in it, reference this in your web service and
make the calls through it.

So you'd have something like this in your WS...

...............................................
private MyBusinessComponent oBusiness ;

public MyWebService
{
oBusiness = new MyBusinessComponent() ;
}

[WebMethod]
public bool SaveBusinessObject(object oObject)
{
oBusiness.SaveBusinessObject(oObject) ;
}
...............................................

rather than...

...............................................
private MyBusinessComponent oBusiness ;

public MyWebService
{
}

[WebMethod]
public bool SaveBusinessObject(object oObject)
{
ValidateObject() ;
MySQLCommand.Execute(sqlString) ;
}
...............................................

"phlakie" wrote:
[color=blue]
> Thanks so much for your help. Taking up your side note. Can you explain
> better what you mean using web methods as facade over my business logic. I'm
> new to both web services and enterprise application programming. Thanx.
>
> "Hammad Rajjoub" wrote:
>[color=green]
> > Hello,
> >
> > You should use Exception handling to cater this scenario.
> >
> > On a side not i would suggest you not to write your business logic (stored
> > proc calls etc) in ur web method. Rather use web methods as facade over your
> > business logic.
> >
> > regards,
> > "phlakie" wrote:
> >[color=darkred]
> > > I made a call to a stored procedure in a web method. The stored procedure
> > > either returns an error or an integer. How do I catch this error in the web
> > > method? Thanks.[/color][/color][/color]
Hammad Rajjoub
Guest
 
Posts: n/a
#5: Nov 23 '05

re: Catching errors in webservices


Yes Steve you are right. Phlakie i would suggest you to read "Enterprise
Solution Patterns" available at msdn.com/patterns web site. Following are a
couple of resources that should help you out with your design and
imeplementation.

Facade Pattern:
http://en.wikipedia.org/wiki/Facade_pattern

Web Service Facade Solution
http://msdn.microsoft.com/library/de...eLegacyApp.asp


best regards,
Hammad


"Steve" wrote:
[color=blue]
> I believe what Hammad means is that you create a class library for example,
> with all of your business logic in it, reference this in your web service and
> make the calls through it.
>
> So you'd have something like this in your WS...
>
> ..............................................
> private MyBusinessComponent oBusiness ;
>
> public MyWebService
> {
> oBusiness = new MyBusinessComponent() ;
> }
>
> [WebMethod]
> public bool SaveBusinessObject(object oObject)
> {
> oBusiness.SaveBusinessObject(oObject) ;
> }
> ..............................................
>
> rather than...
>
> ..............................................
> private MyBusinessComponent oBusiness ;
>
> public MyWebService
> {
> }
>
> [WebMethod]
> public bool SaveBusinessObject(object oObject)
> {
> ValidateObject() ;
> MySQLCommand.Execute(sqlString) ;
> }
> ..............................................
>
> "phlakie" wrote:
>[color=green]
> > Thanks so much for your help. Taking up your side note. Can you explain
> > better what you mean using web methods as facade over my business logic. I'm
> > new to both web services and enterprise application programming. Thanx.
> >
> > "Hammad Rajjoub" wrote:
> >[color=darkred]
> > > Hello,
> > >
> > > You should use Exception handling to cater this scenario.
> > >
> > > On a side not i would suggest you not to write your business logic (stored
> > > proc calls etc) in ur web method. Rather use web methods as facade over your
> > > business logic.
> > >
> > > regards,
> > > "phlakie" wrote:
> > >
> > > > I made a call to a stored procedure in a web method. The stored procedure
> > > > either returns an error or an integer. How do I catch this error in the web
> > > > method? Thanks.[/color][/color][/color]
Closed Thread