soap exception and webservice

I am throwing a soap exception at webservice created in 2.0 using c#.

I have a windows application which is calling webservice.


I am catching a soap exception in try catch whereever there is call to webservice.

I have 2 catch exception block.

1. Soap exception block

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

2. General exception

catch (System.Exception ee)


in all cases all my exception are catching at general exception block.


my webservice is throwing soap exception as


throw new soapException("test", XmlQualifiedName object");


In general exception in getting message as "

Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.

The request failed with the error message:"


And More .... message ..



How a soap exception is converting into general exception at cleint.

or I m missing some things??

2/19/2008 3:11:51 AM 7071 articles. 0 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 24

You should not have to use SoapException. Say in web service you throw System.ArgumentException.  The Framework will "wrap" your ArgumentException in a SoapException and then your client will "unwrap" the SoapException and give you an ArgumentException (inner exception).

2/19/2008 3:23:59 AM

Hello Matt,

we need to throw and user defined exception like ' Invalid soap header" .

instead of soap header i tried to throw a general exception like "Throw new exception("Message" at webservice . yet at client it is catching at general block 



2/19/2008 3:37:33 AM

You could define your own exception type, or just use the message property of an already defined exception type.  As far as I know SOAP is responsible for SoapException.

2/19/2008 3:45:36 AM

I need to throw a soap exception only. at machine in event viewer, there is entry for webservice with some details as

Exception information:

Exception type: SoapException

Exception message: "User defined message"

How ever when same exception is being catch at client end it is catching as general exception


2/19/2008 3:54:58 AM

When exception occurs at .asmx page code , then exception at client it is catching  at soap exception block.

I have implemented a Httphandler to check soap header inside webservice call,

if some exception occurs inside code of http handler, then this exception get catches at  general exception block.

Error while Proccessing Folder creation Request Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.
The request failed with the error message:
        <title>Token validatiion failed. Token value send in user header is invalid or expired</title>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Lucida Console";font-size: .9em}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }

    <body bgcolor="white">

            <span><H1>Server Error in '/Webservice' Application.<hr width=100% size=1 color=silver></H1>

            <h2> <i>Token validatiion failed. Token value send in user header is invalid or expired</i> </h2></span>

            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

            <b> Description: </b>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.


            <b> Exception Details: </b>System.Web.Services.Protocols.SoapException: Token validatiion failed. Token value send in user header is invalid or expired<br><br>

            <b>Source Error:</b> <br><br>

            <table width=100% bgcolor="#ffffcc">

Line 49:                 string strError = "Token validatiion failed. " + "Token value send in user header is invalid or expired";
Line 50:                 ErrorHandler eh = new ErrorHandler(strError, "OnAuthenticate", "WSAuthenticationModule");
<font color=red>Line 51:                 throw WebException.RaiseException("WSAuthenticationModule", "", strError, "101", "OnAuthenticate", FaultCode.Client);
</font>Line 52:             }
Line 53:         }</pre></code>



            <b> Source File: </b>Security\WSAuthenticationModule.cs<b>    Line: </b> 51

            <b>Stack Trace:</b> <br><br>

            <table width=100% bgcolor="#ffffcc">

[SoapException: Token validatiion failed. Token value send in user header is invalid or expired]
   Webservice.WSAuthenticationModule.OnAuthenticate(WebServiceEvents e) in D:\Projects\WorkingFolder for Webservice\WSAuthenticationModule.cs:51
  Webservice.WSAuthenticationModule.OnEnter(Object source, EventArgs eventArgs) in D:\Projects\WorkingFolder for /Webservice\WSAuthenticationModule.cs:114

2/22/2008 9:41:24 AM

Similar Artilces:

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

xml web service --uploading the file to the xml web service
how can we upload the file in the xml web service 1.i mean what will be the return value in the proxy class 2.and how am i going to send the file to the xml web service----regards Bipul Kumar Here are some links to articles that helped us get this done: Hope this helps....

XML Web Service Message from .NET to NonStop SOAP Server
Here's the XML parsing error the NonStop (Tandem) SOAP Server is generating as a result of a Web Service request from my .NET web client.  The web service in question works fine when the XML request comes from the "test" html client.  My question is, is this a lack of carriage returns a problem?  (see trace information below) >> 2008/10/15 14:32:3::Y7H3:<< Unmarshal Error: Invalid input document: Unexpected extra node(s) at the end of the document>> 2008/10/15 14:32:3::Y7H3:<< SoapDocumentHandler::process:Fault occurre...

web service SOAP Headers
If this isn't the right forum, let me know what is.Is there a difference between SOAP serialization and  and XML serialization.I have been reading heavily and am now quite confused.I understand that SOAP serialization produces XML, but perhaps without a specific schema or a scheme very different from XML. In the context of web services, the XML Serializer is used to produce XML in SOAP format. What you may be getting confused about is that there is also a "runtime serialization" subsystem. This can serialize data either using a Binary Formatter, or a SOAP Formatter. It...

Web service in .NET from Java Web Service
Hi there,I'm pretty new to .net (although i have years of experience with the old vb 6, access 2k, as well as java)... and need some with perhaps either some syntax or something.Here is the wsdl.<wsdl:definitions targetNamespace="">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

new UsernameToken exception from web page that consumes web service using soap
I've the following problem, that is generating a UsernameToken in an page:1) a web service (.net 1.1, WSE 2.0 SP3) that requires soap authentication with myUsernameTokenManager implementation 2) a winForm client (.net 1.1, WSE 2.0 SP3) that consumes the web service passing a UsernameToken in the Soap messages. 3) a web client that does the same as the winForm client but with error when generating the UsernameToken to add to the SoapContext. Here is the piece of code: UsernameToken tok = new UsernameToken(CurrentUser.Instance.UserID, CurrentUser.Instance.Password, Passwor...

.NET web services Vs Java Web Services
Hello, does anyone know of a book or good source of information that compares .NET and Java Web Services? (I would like soemthing neutral if possible). I am thinking of approaching this subject for my dissertation? Many Thanks Rob Hi Rob, Last year I had to give a powepoint presentation on Web Services. I noticed some good books at barnes and noble that discussed the subject. These books were specific to Java and discussed Web Services in a very clear fashion. They gave some elementary examples that were easy to understand. I have not yet had the pleasure of creatin .NET Web Servi...

Exception while calling .NET web service | System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
Hi,   We have written a .NET web service which retrieves an xml file from the database. This web service is SSL secured and requires client certificates for connection.   Problem: The web service is throwing an exception while retrieving large files. It works fine when the file size is around 1 MB, but fails with a file size of around 65 MB with the following exception: System.InvalidOperationException: There is an error in XML document (1, 38455668). ---> System.IO.IOException: Unable to read data from the transport connection. ---> System.Net.Sockets.SocketException: ...

Can you return .net web controls in a .net page from a web service?
I've got a problem with a project. I've got to compile an entire .net page and return it as part of a Web Service for display. The problem I have is that I need to add WebControls and functionality to the page so that not only the html content and images are displayed (which I've managed) but that textboxes, labels, buttons and datasets can be displayed also. Essentially I need to make a call from one site for a page, populate the page and return it in a state as though it resided on the same server/webspace as the calling page. Code is currently built as follows into a string: strOpenHT...

SOAP Web Service Problem (problema con un web service)
Please help, I can't read a webservice method (webmethod) from asmx web service, with Delphi firemonkey, In my first try I put a WDSL Importer, and I can retrive data from simplex type (string, booleans, integers) but when the method returns a DataSet, i loose my way. Por favor, ayuda, no puedo leer datos de un web service si el metodo que regresa es un DataSet, el web service esta hecho en así que es un asmx, utilizando el WDSL importes, traje datos sencillos como enteros, boleanos y otros, pero en el caso de arreglos como un DataSet no lo he conseguido, estoy perdido, y l...

Powerbuilder .net msil soap web services
Folks, I came across the following while reading from a "Web Services" link. "A significant difference--and many would say a benefit to the .Net way--is that Microsoft's platform does not require a particular language for developers. <While> Java is both a platform and a <single> language, .Net developers can choose from some 23 supported languages, all of which can interoperate on the same platform. Not all the languages are created by Microsoft, but the company is working with third-party vendors to bring .Net capabilities to languages as diverse as CO...

How to Send raw SOAP/XML to a web service?
I've got the raw SOAP Message in a file and I've got the URL for the webservice. How do I post that SOAP to the URL?thanks,lee After searching thru this site and a few others I put together all of the pieces into one placeThis works://the URL is on the applicationstring strURL = this.txtURL.Text;//go find the raw XMLthis.openFileDialog1.Filter = "XML files (*.xml) | *.xml";this.openFileDialog1.ShowDialog(); //load the XML XmlDocument xmlDoc = new XmlDocument();xmlDoc.Load(this.openFileDialog1.FileName.ToString());//Create the Web request HttpWebRequest request = (HttpWebRequest)...

XML Web Services Encoding but No Soap Message
Hi, I have double byte characters in the content that I am returning using Web Services.  However, the encoding in the xml file returned by Web Services is utf-8 and I am unable to read the content, not even by changing browser encoding setting to the appropriate one.I implemented SoapExtension to modify the xml encoding before it returns to the client, which works when a WinForm calls it, but it doesn't work when a webpage calls it, and here is why:"If you're testing this by hitting the "Invoke" button on the .asmx page, i...

SOAP Extension, .NET and Java Web Service
Hi, All: I have created a .NET web service, it is going to call a Java Web Service. This Java Web Service requires my .NET service send SOAP a message, which is not standard SOAP message. So I need use SOAP extension to try to alter the SOAP message. I call like this retRepsonse = JavaWsProxy.Method(string1); With this call, my .NET web service is not going through SOAP Extension Process method. This is the question I wiuld like to ask, SOAP extension class applies to Web Service method, it means all calls to the method wiii go through the SOAP extension proces method. If this...

C#.NET Web services: Manipulating XML
Hi, I am developing a web service in C#.Net1.1 and a new bee to .NET. I have developed a web method to retrieve the data from database and I want to sent the response in the form of XML.I want to manipulate the dataset to get the desired XML.But I dont know how to do that? Can somebody help me in formatting the XML. Also, once I will format the XML, what return type I should use in web method to get XML file as output. Thanks in advance. First of all, I'm sure you already knnow that .NET 1.1 is rather old. At any rate, make sure you're using the latest service pack for .NET 1.1...

Web resources about - soap exception and webservice -

webservices Articles, Posts, Blogs, Videos - Technorati
— Authority: The job consist in a PHP program that read a file, compose a message (email or sms) and call an API of email provider (Amazon SES) ...

Section: software:webservices © 2012 Condé Nast. All rights reserved. Use of this Site constitutes acceptance of our User Agreement (effective 3/21/12) and Privacy ...

Products - CrunchBase
Product profiles

App Search on Flickr - Application Sharing!
Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to ...

Wikipedia:Press coverage 2005 - Wikipedia, the free encyclopedia
If you add an article, please cite both the title and the source. Note that if you're listing an article from a traditional press wire service ...

Entity–relationship model - Wikipedia, the free encyclopedia
In software engineering , an entity-relationship model ( ER model for short) is an abstract and conceptual representation of data . Entity-relationship ...

Entity-relationship model - Wikipedia, the free encyclopedia
In software engineering , an entity-relationship model ( ER model for short) is an abstract and conceptual representation of data . Entity-relationship ...

IT and Telecommunications Jobs in Melbourne Metro - MyCareer
Find IT and Telecommunications Jobs in Melbourne Metro on MyCareer. Fresh IT and Telecommunications Jobs posted daily. Free email alerts and ...

AWS Elastic Beanstalk: A Quick and Simple Way into the Cloud
Flexibility is one of the key principles of Amazon WebServices - developers can select any programming language and software package,any operating ...

How To Use the Amazon SDK for Android to Upload Photos to Amazon S3
This article demonstrates how to use the AWS SDK for Android to upload an image to Amazon Simple Storage Service (S3) from your mobile device ...

Resources last updated: 11/23/2015 10:24:01 PM