473,785 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serialising soap faults

Hello,
I'm trying to build a C# client to consume an AXIS Web Service (running SOAP
over HTTP). The Web Service encodes full server-side exception traces in the
Soap Fault > Detail element using
complex type structures declared in the WSDL file.
I have had absolutely no luck working out how I can deserialize the custom
server exception object out of the detail element.
I have tried XmlSerializer as suggested in the mailing list with absolutely
no luck.

try
{
<<<< e.g. some operation >>>>
}
catch (System.Web.Ser vices.Protocols .SoapException e)
{

try
{
System.Xml.Seri alization.XmlSe rializer ser=
new System.Xml.Seri alization.XmlSe rializer(typeof
(FdkException)) ;

System.IO.Strin gReader sr= new
System.IO.Strin gReader(e.Detai l.InnerXml);

FdkException fault= (FdkException) ser.Deserialize (new
System.Xml.XmlT extReader(sr));

FdkException fault= (FdkException) ser.Deserialize (new
System.Xml.XmlT extReader(strea m));
}
catch (Exception ex)
{
System.Console. WriteLine(ex.to String());
throw;
}
}

I set SoapType options in the FdkException class(generated through wsdl) as
mentioned in the mailing list
....
[Serializable]
[System.Xml.Seri alization.XmlTy pe("Fault",
Namespace="http ://xmlns.mycompany .com/content/ws")]
[System.Xml.Seri alization.XmlRo ot("Fault",
Namespace="http ://xmlns.mycompany .com/content/ws")]
[System.Xml.Seri alization.SoapT ypeAttribute("F dkException",
"http://xmlns.mycompany .com/content/ws")]

public class FdkException
{
public string errorCode;
public FdkExceptionEnt ry[] exceptionEntrie s;
public string serverStackTrac eId;
}
[Serializable]
[SoapTypeAttribu te(“FdkExcept ionEntry”,"ht tp://xmlns.mycompany .com/app/ws")]

public class FdkExceptionEnt ry
{
public string errorCode;
public long id;
public string serverStackTrac eId;
}
This deserialization approach resulted in an exception:

Exception Type: System.InvalidO perationExcepti on
Message: <fault xmlns='http://xmlns.mycompany .com/content/ws'> was not
expected.

Below is the SOAP message returned from the server on an invalid operation
attempt (including Fault):-

<?xml version="1.0" encoding="utf-8"?><soapenv:En velope
xmlns:soapenv=" http://schemas.xmlsoap .org/soap/envelope/"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"><soap env:Body>

<soapenv:Fault> <faultcode>soap env:Server.user Exception</faultcode><faul tstring>MYCOMPA NY.FDK.Aggregat eError: MYCOMPANY.FDK.A ggregateError</faultstring>

<detail> =====>> This is what we are tying to deserialise to
FdkException

<ns1:fault xsi:type="ns1:F dkException"
xmlns:ns1="http ://xmlns.mycompany .com/content/ws"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">

<exceptionEntri es soapenc:arrayTy pe="ns1:FdkExce ptionEntry[1]"
xsi:type="soape nc:Array"
xmlns:soapenc=" http://schemas.xmlsoap .org/soap/encoding/">

<exceptionEntri es xsi:type="ns1:F dkExceptionEntr y">

<detailedErrorC ode
xsi:type="xsd:s tring">MYCOMPAN Y.FDK.ServerErr or</detailedErrorCo de>

<errorCode
xsi:type="xsd:s tring">MYCOMPAN Y.FDK.Unexpecte dError</errorCode>

<id xsi:type="xsd:l ong">0</id>

<serverStackTra ceId
xsi:type="xsd:s tring">22-1132729995032</serverStackTrac eId>

</exceptionEntrie s>

</exceptionEntrie s>

<detailedErrorC ode
xsi:type="xsd:s tring">MYCOMPAN Y.FDK.Aggregate Error</detailedErrorCo de>

<errorCode
xsi:type="xsd:s tring">MYCOMPAN Y.FDK.Aggregate Error</errorCode>

<serverStackTra ceId xsi:type="xsd:s tring"></serverStackTrac eId>

</ns1:fault>

</detail>

</soapenv:Fault></soapenv:Body></soapenv:Envelop e>

Is anything wrong with the XML generated for custom exceptions in the detail
element.

many thanks,

--
--gaurav
Nov 24 '05 #1
0 1331

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

Similar topics

0
1388
by: Vince C. | last post by:
Hi. I'd like to return warnings to a soap client instead of faults. Soap faults generally trigger an exception in clients (VBScript, JavaScript, VB,...). But I'd like to return a warning instead, i.e. a standard soap message that must not evaluate to an error but to a notification meaningful to the client. E.g. I'd like to perform an action on the server-side. If that action has already been performed and is not critical a simple...
3
4253
by: Moshe Kravchik | last post by:
Hi! We have a Web Service written in ATL Server and a client written in Java using Axis. When something goes wrong on the server side, it returns an HRESULT of the error which is translated into the SoapFault. The problem is that the SoapFault is interpreted by Axis not as a SoapFaultException, but as a more generic AxisFault exception with all the info we put in the soap fault lost. Has anyone manage to get this to work? Please...
3
10296
by: JRey | last post by:
Does .Net generate the classes for Faults when they are specified in the WSDL. I tried defining them and then generating a proxy, and it did not appear to do it. On the Java side it did generate the class and the ability to serialize that class when putting it on the wire. I was hoping a .Net client would create the appropriate exception class defined in the WSDL and deserialize the message into the appropriate exception class.
1
1948
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/">
1
3769
by: martin | last post by:
Hi, Some of my webservice peers return SOAP faults using a "HTTP 200 OK" reply and others use a "HTTP 500 Internal Server Error" instead. I was wondering if there is some kind of standard for SOAP over HTTP (or, more specifically where I can find such a beast) that regulates these things? And, which one is correct? Using HTTP 200 OK or
2
3198
by: Yossi | last post by:
VS2005 I have a web service that runs just fine. On the server side I always return a string that either indicates failure or returns the requested data. I want to raise SOAPExceptions instead of returning a string with the value set to "method failed". So I modified my code, but I am unable to test it. Right now, from VS2005, I am right clicking on my web service and then clicking on "Display in browser". I then click on my web...
3
5629
by: Tomsawyer2kin_hotmail | last post by:
Hi, I created a custom Exception Class as Public Class CSTException : Inherits System.ApplicationException ' required to over ride the base class method Sub New(ByVal ExceptionCode As AppExCodes) MyBase.New(CStr(ExceptionCode)) End Sub end class
3
7580
by: =?Utf-8?B?TWFucHJlZXQgU3VzaGls?= | last post by:
I am having a Webservice within which i am throwing SOAP Exceptions and therefore whenever something wrong happens a SOAP fault comes up in the response - see below: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...
0
3138
by: Default User | last post by:
I work on creating test cases for a SOAP-based set of servers, using soapUI. I received and updated set of WSDL and schema files, and when I made new tests and mock server operations, all of the ones that had been working now returned a SOAP fault. The faults look something like: <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Body> <soap:Fault> <soap:Code>
0
9646
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9483
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
10346
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
10157
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
9956
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...
0
8982
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
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...
0
6742
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.