473,545 Members | 2,081 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 13900
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
7445
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;...
7
5916
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...
3
9780
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...
0
4337
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...
6
2110
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
1930
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"...
0
1903
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
1896
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
5954
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:...
0
7468
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...
0
7401
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...
0
7656
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. ...
1
7423
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5972
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5329
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...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1884
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

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.