473,698 Members | 2,346 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlSerializatio n 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:part ner.xxxxx.com">
<RequestID>23 9</RequestID>
<TimeStamp>20 06-03-06T17:10:51.466 2331-06:00</TimeStamp>
<Subject xmlns:ns1="urn: partnermapping. xxxxxx.com"
xsi:type="ns1:P artnerMapping">
<AccountID>9840 1</AccountID>
</Subject>
</Partner>

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

Thanks,

pfrisbie

Mar 7 '06 #1
4 4006
pf******@hotmai l.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
XmlSerializatio n 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 XmlSerializatio n 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.Seri alization.XmlEl ementAttribute( Namespace="http ://the.namespace/")]
public object theUnknownEleme nt;

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

[System.Xml.Seri alization.XmlIn clude( typeof( OneSpecificType ))]
public class GeneratedStub:
System.Web.Serv ices.Protocols. SoapHttpClientP rotocol
{...}

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
3479
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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <one xsi:type="xsd:string">test</one> </zero>
3
9379
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 outs with datasets and datatables (and navigating through the filled datatable)... Just when I thought I had gotten the hang of it, another problem arose: I can't seem to access the "xsi:type" attribute. That is, the XML file looks
0
2207
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 of it, another problem arose: I can't seem to access the "xsi:type" attribute. That is, the XML file looks something like this: <situation>
6
10796
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 FileStream(NavCmdFile, FileMode.Create, FileAccess.Write, FileShare.None); XmlSerializer xmlFmt = new XmlSerializer(someObject.GetType());
1
2296
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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="java:ucles.cbtas.model.Centre"> <number>25279</number> <customer-id>16</customer-id> </centre>
0
1156
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 these objects, they are not set to null, but int=0, bool=false etc. My client expects null ints to be Int32.MinValue, for example. SO, what I have done is write a filter for the client, which transforms the incoming SOAP packets with XSL.
0
1983
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> <search xmlns="urn:messages_2_5.platform.webservices.netsuite.com"> <searchRecord xsi:type="ns1:ContactSearch" xmlns:ns1="urn:relationships_2_5.lists.webservices.netsuite.com"> <ns1:customerJoin xsi:type="ns2:CustomerSearchBasic"
1
1987
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> </xsl:attribute>
2
2338
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 xmlns="http://thisUrl.com/Types"> <VehicleConfiguration xsi:type="CarConfig" Manufacturer="Porsche" Model="911" SerialNumber="1234567890-A" Color="red" />
0
8676
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
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
9164
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
9029
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...
1
8898
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6524
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
5860
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3051
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.