473,397 Members | 2,099 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.

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.Services.Protocols.SoapException e)
{

try
{
System.Xml.Serialization.XmlSerializer ser=
new System.Xml.Serialization.XmlSerializer(typeof
(FdkException));

System.IO.StringReader sr= new
System.IO.StringReader(e.Detail.InnerXml);

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

FdkException fault= (FdkException) ser.Deserialize(new
System.Xml.XmlTextReader(stream));
}
catch (Exception ex)
{
System.Console.WriteLine(ex.toString());
throw;
}
}

I set SoapType options in the FdkException class(generated through wsdl) as
mentioned in the mailing list
....
[Serializable]
[System.Xml.Serialization.XmlType("Fault",
Namespace="http://xmlns.mycompany.com/content/ws")]
[System.Xml.Serialization.XmlRoot("Fault",
Namespace="http://xmlns.mycompany.com/content/ws")]
[System.Xml.Serialization.SoapTypeAttribute("FdkExc eption",
"http://xmlns.mycompany.com/content/ws")]

public class FdkException
{
public string errorCode;
public FdkExceptionEntry[] exceptionEntries;
public string serverStackTraceId;
}
[Serializable]
[SoapTypeAttribute(“FdkExceptionEntry”,"http://xmlns.mycompany.com/app/ws")]

public class FdkExceptionEntry
{
public string errorCode;
public long id;
public string serverStackTraceId;
}
This deserialization approach resulted in an exception:

Exception Type: System.InvalidOperationException
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:Envelope
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"><soapenv:Body>

<soapenv:Fault><faultcode>soapenv:Server.userExcep tion</faultcode><faultstring>MYCOMPANY.FDK.AggregateErro r: MYCOMPANY.FDK.AggregateError</faultstring>

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

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

<exceptionEntries soapenc:arrayType="ns1:FdkExceptionEntry[1]"
xsi:type="soapenc:Array"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

<exceptionEntries xsi:type="ns1:FdkExceptionEntry">

<detailedErrorCode
xsi:type="xsd:string">MYCOMPANY.FDK.ServerError</detailedErrorCode>

<errorCode
xsi:type="xsd:string">MYCOMPANY.FDK.UnexpectedErro r</errorCode>

<id xsi:type="xsd:long">0</id>

<serverStackTraceId
xsi:type="xsd:string">22-1132729995032</serverStackTraceId>

</exceptionEntries>

</exceptionEntries>

<detailedErrorCode
xsi:type="xsd:string">MYCOMPANY.FDK.AggregateError </detailedErrorCode>

<errorCode
xsi:type="xsd:string">MYCOMPANY.FDK.AggregateError </errorCode>

<serverStackTraceId xsi:type="xsd:string"></serverStackTraceId>

</ns1:fault>

</detail>

</soapenv:Fault></soapenv:Body></soapenv:Envelope>

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

many thanks,

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

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

Similar topics

0
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...
3
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...
3
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...
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...
1
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...
2
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...
3
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...
3
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"...
0
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...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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 projectplanning, 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.