473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Throwing a Soap Exception from a webservice

Hi,

I have written a web service for accessing data from a database. I have a
method in the webservice which returns a dataset. I am trying to implement
error handling by using the try...catch...finally structure.

Now, the method's logic in the try block returns a dataset while the the
code in the 'catch' block throws an exception object of the SoapException
class. Before, returning an exception to the calling code, I build up an
XML node structure and pass it to the constructor of the SoapException object.

What I expect to see is the Exception in an XML Format instead of the data
which being returned under normal circumstances. However, what I see is just
a 'HTTP 500 Internal Server Error. Page not displayed'. I have debugged the
code and it does go throught the catch block and the soapexception is
returned.

The outline for the code is as follows:

[WebMethod]
public DataSet ABC()
{
try
{
-
-
-
if (x<y)
{
return ds;
}
else
{
throw RaiseException(,,,,,,)
}

}
catch (SoapException soapEx)
{
EventLog.WriteEntry(soapEx.Source, soapEx.Message);
throw soapEx;
}
catch(Exception ex)
{
EventLog.WriteEntry(ex.Source, ex.Message);
throw
RaiseException("Para1", "Para2"
"Para3",Para4,"Para5",Para6,Para7);
}

}


public SoapException RaiseException(Para1,
Para2,
Para3,
Para4,
Para5,
Para6)
{
_
_
_
_
SoapException soapEx = new SoapException(errorMessage,
faultCodeLocation, uri,
rootNode);
//Raise the exception back to the caller
return soapEx;
}

}

Can I follow the approach above? i.e return a SoapException object in a
method of return type dataset or there is another way of doing it? Please
advise.

Cheers
Mar 18 '07 #1
3 13891
Just wanted to add that I am working on .Net 1.1

"Hemil" wrote:
Hi,

I have written a web service for accessing data from a database. I have a
method in the webservice which returns a dataset. I am trying to implement
error handling by using the try...catch...finally structure.

Now, the method's logic in the try block returns a dataset while the the
code in the 'catch' block throws an exception object of the SoapException
class. Before, returning an exception to the calling code, I build up an
XML node structure and pass it to the constructor of the SoapException object.

What I expect to see is the Exception in an XML Format instead of the data
which being returned under normal circumstances. However, what I see is just
a 'HTTP 500 Internal Server Error. Page not displayed'. I have debugged the
code and it does go throught the catch block and the soapexception is
returned.

The outline for the code is as follows:

[WebMethod]
public DataSet ABC()
{
try
{
-
-
-
if (x<y)
{
return ds;
}
else
{
throw RaiseException(,,,,,,)
}

}
catch (SoapException soapEx)
{
EventLog.WriteEntry(soapEx.Source, soapEx.Message);
throw soapEx;
}
catch(Exception ex)
{
EventLog.WriteEntry(ex.Source, ex.Message);
throw
RaiseException("Para1", "Para2"
"Para3",Para4,"Para5",Para6,Para7);
}

}


public SoapException RaiseException(Para1,
Para2,
Para3,
Para4,
Para5,
Para6)
{
_
_
_
_
SoapException soapEx = new SoapException(errorMessage,
faultCodeLocation, uri,
rootNode);
//Raise the exception back to the caller
return soapEx;
}

}

Can I follow the approach above? i.e return a SoapException object in a
method of return type dataset or there is another way of doing it? Please
advise.

Cheers
Mar 19 '07 #2
Hi,
If the client is using HTTP-GET or HTTP-POST, ASP.NET returns an HTTP
Internal Server Error (Error code 500) to the client.
Below two links elaborates more on this.
http://safari.peachpit.com/0735617201/IDAHVHT
http://msdn2.microsoft.com/en-us/library/aa480514.aspx
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Hemil" wrote:
Hi,

I have written a web service for accessing data from a database. I have a
method in the webservice which returns a dataset. I am trying to implement
error handling by using the try...catch...finally structure.

Now, the method's logic in the try block returns a dataset while the the
code in the 'catch' block throws an exception object of the SoapException
class. Before, returning an exception to the calling code, I build up an
XML node structure and pass it to the constructor of the SoapException object.

What I expect to see is the Exception in an XML Format instead of the data
which being returned under normal circumstances. However, what I see is just
a 'HTTP 500 Internal Server Error. Page not displayed'. I have debugged the
code and it does go throught the catch block and the soapexception is
returned.

The outline for the code is as follows:

[WebMethod]
public DataSet ABC()
{
try
{
-
-
-
if (x<y)
{
return ds;
}
else
{
throw RaiseException(,,,,,,)
}

}
catch (SoapException soapEx)
{
EventLog.WriteEntry(soapEx.Source, soapEx.Message);
throw soapEx;
}
catch(Exception ex)
{
EventLog.WriteEntry(ex.Source, ex.Message);
throw
RaiseException("Para1", "Para2"
"Para3",Para4,"Para5",Para6,Para7);
}

}


public SoapException RaiseException(Para1,
Para2,
Para3,
Para4,
Para5,
Para6)
{
_
_
_
_
SoapException soapEx = new SoapException(errorMessage,
faultCodeLocation, uri,
rootNode);
//Raise the exception back to the caller
return soapEx;
}

}

Can I follow the approach above? i.e return a SoapException object in a
method of return type dataset or there is another way of doing it? Please
advise.

Cheers
Mar 19 '07 #3
Hi Manish,

I read the msdn article and followed it. The problem in my case however is
that:

When, I try (for example)
Throw New Exception("Something bad happened")

It doesn't give me the following SOAP output as per what the article suggests.
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>System.Web.Services.Protocols.SoapExc eption: Server was
unable to process request. ---System.Exception: Something bad
happened at AYS17Sept2002.Service1.CallFault() in
c:\inetpub\wwwroot\AYS17Sept2002\Service1.asmx.vb: line 49
--- End of inner exception stack trace ---</faultstring>
<detail />
</soap:Fault>

Instead it gives me this:
Something bad happened.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Exception: Something bad happened

I understand that the asp.net asmx handler catches the exception and
transforms it into a SOAP fault. But it certainly isn't doing it in my setup.

Any ideas?
Cheers

"Manish Bafna" wrote:
Hi,
If the client is using HTTP-GET or HTTP-POST, ASP.NET returns an HTTP
Internal Server Error (Error code 500) to the client.
Below two links elaborates more on this.
http://safari.peachpit.com/0735617201/IDAHVHT
http://msdn2.microsoft.com/en-us/library/aa480514.aspx
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Hemil" wrote:
Hi,

I have written a web service for accessing data from a database. I have a
method in the webservice which returns a dataset. I am trying to implement
error handling by using the try...catch...finally structure.

Now, the method's logic in the try block returns a dataset while the the
code in the 'catch' block throws an exception object of the SoapException
class. Before, returning an exception to the calling code, I build up an
XML node structure and pass it to the constructor of the SoapException object.

What I expect to see is the Exception in an XML Format instead of the data
which being returned under normal circumstances. However, what I see is just
a 'HTTP 500 Internal Server Error. Page not displayed'. I have debugged the
code and it does go throught the catch block and the soapexception is
returned.

The outline for the code is as follows:

[WebMethod]
public DataSet ABC()
{
try
{
-
-
-
if (x<y)
{
return ds;
}
else
{
throw RaiseException(,,,,,,)
}

}
catch (SoapException soapEx)
{
EventLog.WriteEntry(soapEx.Source, soapEx.Message);
throw soapEx;
}
catch(Exception ex)
{
EventLog.WriteEntry(ex.Source, ex.Message);
throw
RaiseException("Para1", "Para2"
"Para3",Para4,"Para5",Para6,Para7);
}

}


public SoapException RaiseException(Para1,
Para2,
Para3,
Para4,
Para5,
Para6)
{
_
_
_
_
SoapException soapEx = new SoapException(errorMessage,
faultCodeLocation, uri,
rootNode);
//Raise the exception back to the caller
return soapEx;
}

}

Can I follow the approach above? i.e return a SoapException object in a
method of return type dataset or there is another way of doing it? Please
advise.

Cheers
Mar 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Oliver Hirschi | last post by:
Hi, I am really confused. I try to call a soap-method on a server with one parameter and I like to get the return-parameter of this method, but I get ever the following exception by invoking the...
7
by: Q. John Chen | last post by:
All, I have a WebService created in .NET. I have VB6 Client consume the WebService (using Soap ToolKit 3.0) But I have couple user who got error accessing the WebServer with error message...
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
0
by: Matt Wood | last post by:
Hi, I have written a Web Service for a customer which expects a SOAP message with Document/Literal encoding, and uses RoutingStyle=SoapServiceRoutingStyle.RequestElement to route the SOAP body...
6
by: A.M-SG | last post by:
Hi, We are developing a SmartClient application and we are planning to expose business objects layer to SmartClient application by using ASP.NET SOAP web services.
1
by: PaulO | last post by:
I am making a webservice call into to a PeopleSoft service and everything works except raising exceptions. As an example if I fail authentication I get the following response: <?xml...
0
by: Samuel Zallocco | last post by:
Hi all, I've a problem with PHP5 + PEAR::SOAP. I Have the following 2 script that implements a simple web service: The Server Code running on WinXP + PHP5 + Apache 2.x:...
2
by: Anthony Biondo Jr | last post by:
I was wondering how to handle an error in a web service. If our web service encounters a connection error or any other error what is the best practice for returning an error? Do you return a...
1
Plater
by: Plater | last post by:
I have a webservice that claims the following: SOAP 1.1 The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values. POST...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.