473,396 Members | 1,805 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,396 software developers and data experts.

XmlSerialization serializing with xsi:type specified

I am developing a Web Services interface with C# and our partner is
using Java (Axis 1.1). They require me to include xsi:types in the
SOAP Messages I send them. For example:

<Partner xmlns="urn:partner.xxxxx.com">
<RequestID>239</RequestID>
<TimeStamp>2006-03-06T17:10:51.4662331-06:00</TimeStamp>
<Subject xmlns:ns1="urn:partnermapping.xxxxxx.com"
xsi:type="ns1:PartnerMapping">
<AccountID>98401</AccountID>
</Subject>
</Partner>

Is this possible with XmlSerialization? I searched all over and cannot
find any examples of this. How do I specify it using .Net
XmlSerialization?

Thanks,

pfrisbie

Mar 7 '06 #1
4 3950
pf******@hotmail.com wrote:
I am developing a Web Services interface with C# and our partner is
using Java (Axis 1.1). They require me to include xsi:types in the
SOAP Messages I send them. For example:
I had the opposite problem. The web services were not sending me the
xsi:type that I required to deserialize properly a certain element.

What i did was a SoapExtension that searched for the element and if the
xsi:type was not present it would add it manually manipulating the
XmlDocument.
pfrisbie


--
David Mediavilla

Mar 8 '06 #2
David, you are right, a SOAP Extension would work. I'm wondering if
your WebService required an xsi:type then that suggests that
XmlSerialization is aware of xsi:types so it should be able to
deserialize them as well. Is there are attribute or something in your
classes that looks like it sets the xsi:type? Thanks -- Pat.

Mar 8 '06 #3
I meant to say: "... that suggests that XmlSerialization is aware of
xsi:types so it should be able to SERIALIZE them as well. ..." -- Pat

Mar 8 '06 #4
My code required an xsi:type because that element was declared as:

[System.Xml.Serialization.XmlElementAttribute(Names pace="http://the.namespace/")]
public object theUnknownElement;

It was an object because each service provided a different type. I have
several SoapHttpClientProtocol that deal with each service:

[System.Xml.Serialization.XmlInclude( typeof( OneSpecificType))]
public class GeneratedStub:
System.Web.Services.Protocols.SoapHttpClientProtoc ol
{...}

The services did not provide an xsi:type because they provided always
the same type. It was me who had to be flexible.

My testing Web Service also had [XmlInclude( typeof(
OneSpecificType))].

You could also examine their WSDL and hack it to turn Subject into a
anyType or Choice. Look also abstract elements (
http://www.w3.org/TR/xmlschema-0/#abstract ).
Generate code from the hacked WSDL and compare with what you have.
If you don't have Java's WSDL, try to generate one from your client.

--
David Mediavilla

Mar 8 '06 #5

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

Similar topics

8
by: johnsocs | last post by:
How do you validate the following XML document, I'm having problems with element 'one' with the attribute xsi:type="xsd:string" <?xml version="1.0" encoding="UTF-8"?> <zero...
3
by: Carl Lindmark | last post by:
*Cross-posting from microsoft.public.dotnet.languages.csharp, since I believe the question is better suited in this XML group* Hello all, I'm having some problems understanding all the ins and...
0
by: Carl Lindmark | last post by:
Hello all, I'm having some problems understanding all the ins and outs with datasets and datatables (and navigating through the filled datatable)... Just when I thought I had gotten the hang...
6
by: geoffrobinson | last post by:
Hi, I'm serializing an object using XmlSerializer. It is serializing, but we are getting errors upon deserialization. We use the following code to serialize: FileStream fs = new...
1
by: PeterW | last post by:
I have a bit of xml that I am trying to create an xsd schema from. A very simplified version is as follows: <?xml version="1.0" encoding="UTF-8"?> <centre...
0
by: Adam | last post by:
I am attempting to get a .net 1.1 client to interoperate with a .net 2.0 web service. The web service returns objects that contains fields of nullable types. Obviously when the 1.1 client receives...
0
by: frugalprogrammer | last post by:
I'm pretty sure what I'm up against now is a namespace issue and/or a misunderstanding of how to use SoapVar. From the NetSuite docs, the request should look something like: <soapenv:Body>...
1
by: luthriaajay | last post by:
I am creating an element called 'i:Details' which has an attribute called xsi:type <xsl:element name="i:Details"> <xsl:attribute name="xsi.type"> xsl:text>i:vanilla.stock</xsl:text>...
2
by: oh.i.love.spam | last post by:
This is just an example... I don't have the access/ability to upload the actual code. Here is the meat in the XML that is returned from the $client- <VesselConfigurations...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...
0
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...

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.