473,881 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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...f inally 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.WriteE ntry(soapEx.Sou rce, soapEx.Message) ;
throw soapEx;
}
catch(Exception ex)
{
EventLog.WriteE ntry(ex.Source, ex.Message);
throw
RaiseException( "Para1", "Para2"
"Para3",Para4," Para5",Para6,Pa ra7);
}

}


public SoapException RaiseException( Para1,
Para2,
Para3,
Para4,
Para5,
Para6)
{
_
_
_
_
SoapException soapEx = new SoapException(e rrorMessage,
faultCodeLocati on, 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 13951
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...f inally 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.WriteE ntry(soapEx.Sou rce, soapEx.Message) ;
throw soapEx;
}
catch(Exception ex)
{
EventLog.WriteE ntry(ex.Source, ex.Message);
throw
RaiseException( "Para1", "Para2"
"Para3",Para4," Para5",Para6,Pa ra7);
}

}


public SoapException RaiseException( Para1,
Para2,
Para3,
Para4,
Para5,
Para6)
{
_
_
_
_
SoapException soapEx = new SoapException(e rrorMessage,
faultCodeLocati on, 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...f inally 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.WriteE ntry(soapEx.Sou rce, soapEx.Message) ;
throw soapEx;
}
catch(Exception ex)
{
EventLog.WriteE ntry(ex.Source, ex.Message);
throw
RaiseException( "Para1", "Para2"
"Para3",Para4," Para5",Para6,Pa ra7);
}

}


public SoapException RaiseException( Para1,
Para2,
Para3,
Para4,
Para5,
Para6)
{
_
_
_
_
SoapException soapEx = new SoapException(e rrorMessage,
faultCodeLocati on, 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("Some thing bad happened")

It doesn't give me the following SOAP output as per what the article suggests.
<soap:Fault>
<faultcode>soap :Server</faultcode>
<faultstring>Sy stem.Web.Servic es.Protocols.So apException: Server was
unable to process request. ---System.Exceptio n: Something bad
happened at AYS17Sept2002.S ervice1.CallFau lt() in
c:\inetpub\wwwr oot\AYS17Sept20 02\Service1.asm x.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.Exceptio n: 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...f inally 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.WriteE ntry(soapEx.Sou rce, soapEx.Message) ;
throw soapEx;
}
catch(Exception ex)
{
EventLog.WriteE ntry(ex.Source, ex.Message);
throw
RaiseException( "Para1", "Para2"
"Para3",Para4," Para5",Para6,Pa ra7);
}

}


public SoapException RaiseException( Para1,
Para2,
Para3,
Para4,
Para5,
Para6)
{
_
_
_
_
SoapException soapEx = new SoapException(e rrorMessage,
faultCodeLocati on, 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
7459
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 call: -------------------------------------- No Deserializer found to deserialize a &apos;http://schemas.xmlsoap.org/soap/encoding/:string&apos; using encoding style &apos;http://schemas.xmlsoap.org/soap/encoding/&apos;.
7
5933
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 "Unable to handle request without a valid parameter ..." After hours of research, my conclusion is that the firewall treat "SOAPAction" as unknow header and blocked it.
3
9799
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 response. As a result of seraching news groups I guessed that the SOAP response defines an array element in a way that causes the dotnet deserialization routines to put the content in a generic object array (object) BUT the content is supposed to...
0
4376
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 message to my Web Method. The Web Method expects a string as its parameter and then feeds that string to an XML deserializer which maps the XML elements contained within the string to my custom objects, then performs an insert/update on an SQL...
6
2141
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
1950
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 version="1.0"?> <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
0
1921
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: ---------------------------------------------------- <?php require_once('SOAP/Server.php'); require_once('SOAP/Disco.php');
2
1912
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 blank result with an error attached or is there some other way to do this? thanks, Anthony
1
5986
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 /testdb/UnitReporting.asmx HTTP/1.1 Host: localhost Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://mylocation/UpdateInformation"
0
9928
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9776
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11100
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10718
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10402
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7953
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4196
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.