•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the XML, XSLT and XPATH section within the Software Development category of DaniWeb, a massive community of 455,962 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,602 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our XML, XSLT and XPATH advertiser: Programming Forums
Views: 6389 | Replies: 0
![]() |
•
•
Join Date: Nov 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hi there
I'm hoping there's an easy answer to a (hopefully) not too long-winded issue...
I'm building a C# web client using a proxy wsdl.exe'd from a wsdl file and six schemas, each in a different namespace. Some schemas extend complex types in others. When i get a soap:Fault from my test server it could contain a serialized exception object (called fault) from one of two of these schemas (and different namespaces, call them xmlns:b0="ns1" and xmlns:eb="ns2"), yet the root element of the SoapException.Detail node will remain the same (in "ns1"). The prefix declaration is in the soap:Fault node of the response.
Now, if the object i'm trying to desrialize is defined in the same schema as the root element <b0:faultResp> (e.g. <b0:fault xsi:type="b0:ThisEx">) i create an XmlSerializer with this default namespace and it deserializes no problem, and the root element of the Detail node becomes <b0:faultResp xmlns:b0="ns1">. If it's defined in the other schema (e.g. <b0:fault xsi:type="eb:ThatEx">). i get an error: "Namespace prefix 'eb' is not declared", yet both prefixes are defined in the <soap:Fault xmlns:b0="ns1" xmlns:eb="ns2"> node
I understand that XmlSerializer.Serialize method takes an XmlNamespaces parameter which allows you to add any other namespaces it needs when serializing, but XmlSerializer.Desrialize doesn't; i can't find any way to at all. SoapFormatter.deserialize didn't work nor did using XmlSerializerFactory to create the serializer. So my questions then:
1. Is there some way to specify additional namespaces (like that xmlns:eb="ns2" guy) to the XmlSerializer object before deserializing?
2. Is there a way to extract the namespace declarations in the soap:Fault node from the SoapException the webmethod catches?
3. Is there a way of doing this without worrying about the namespaces at all?
The Fiddler'd response looks like this:
Excerpt from schema 1 (xmlns:b0="ns1")
Excerpt from schema 2 (xmlns:eb="ns2")
What I'm looking for is to deserialize the <b0:faultResp> into an object of type FaultResp, with a property of type ThatEx, that has a string property called desc.
Any help appreciated.
Dave
I'm hoping there's an easy answer to a (hopefully) not too long-winded issue...
I'm building a C# web client using a proxy wsdl.exe'd from a wsdl file and six schemas, each in a different namespace. Some schemas extend complex types in others. When i get a soap:Fault from my test server it could contain a serialized exception object (called fault) from one of two of these schemas (and different namespaces, call them xmlns:b0="ns1" and xmlns:eb="ns2"), yet the root element of the SoapException.Detail node will remain the same (in "ns1"). The prefix declaration is in the soap:Fault node of the response.
Now, if the object i'm trying to desrialize is defined in the same schema as the root element <b0:faultResp> (e.g. <b0:fault xsi:type="b0:ThisEx">) i create an XmlSerializer with this default namespace and it deserializes no problem, and the root element of the Detail node becomes <b0:faultResp xmlns:b0="ns1">. If it's defined in the other schema (e.g. <b0:fault xsi:type="eb:ThatEx">). i get an error: "Namespace prefix 'eb' is not declared", yet both prefixes are defined in the <soap:Fault xmlns:b0="ns1" xmlns:eb="ns2"> node
I understand that XmlSerializer.Serialize method takes an XmlNamespaces parameter which allows you to add any other namespaces it needs when serializing, but XmlSerializer.Desrialize doesn't; i can't find any way to at all. SoapFormatter.deserialize didn't work nor did using XmlSerializerFactory to create the serializer. So my questions then:
1. Is there some way to specify additional namespaces (like that xmlns:eb="ns2" guy) to the XmlSerializer object before deserializing?
2. Is there a way to extract the namespace declarations in the soap:Fault node from the SoapException the webmethod catches?
3. Is there a way of doing this without worrying about the namespaces at all?
The Fiddler'd response looks like this:
<?xml version="1.0"?> <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <Body> <soap:Fault xmlns:b0="ns1" xmlns:eb="ns2" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <faultcode xmlns="">soap:Server</faultcode> <faultstring xmlns="">An exception was thrown on the server/faultstring> <detail xmlns=""> <b0:faultResp> <b0:fault xsi:type="eb:ThatEx"> <b0:desc>That other exception occurred</b0:desc> </b0:fault> </b0:faultResp> </detail> </soap:Fault> </Body> </Envelope>
Excerpt from schema 1 (xmlns:b0="ns1")
<element name="faultResp" type="i0:FaultResp"> <annotation> <documentation>A fault.</documentation> </annotation> </element> <complexType name="faultResp"> <annotation> <documentation>A fault.</documentation> </annotation> <complexContent> <extension base="i0:BaseResp"> <sequence> <element minOccurs="1" maxOccurs="1" name="fault" type="i0:Fault"/> </sequence> </extension> </complexContent> </complexType> ... <complexType name="Fault" abstract="true"> <annotation> <documentation>A generic fault.</documentation> </annotation> <sequence> <element minOccurs="1" maxOccurs="1" name="desc" type="i0:Msg"> <annotation> <documentation>description of the fault</documentation> </annotation> </element> </sequence> </complexType>
Excerpt from schema 2 (xmlns:eb="ns2")
<complexType name="ThatEx"> <annotation> <documentation>That Other exception.</documentation> </annotation> <complexContent> <extension base="b0:Fault" /> </complexContent> </complexType>
Any help appreciated.
Dave
![]() |
•
•
•
•
•
•
•
•
DaniWeb XML, XSLT and XPATH Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Namespaces (C#)
- About the namespaces (C++)
- Adding controls into a ListView (Visual Basic 4 / 5 / 6)
- adding quick reply to a phpbb board (Growing an Online Community)
- Adding Totals from Listbox DB (DAO) (Visual Basic 4 / 5 / 6)
- My ie keeps adding favorites w/out my permission and . . . (Web Browsers)
- adding totals in listboxes (Visual Basic 4 / 5 / 6)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: Problem with display parent & child nodes if XML not follows an Hierar Struc. in c#
- Next Thread: need help


Linear Mode