473,725 Members | 2,264 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 4009
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
3481
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
9386
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
2213
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
10808
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
2297
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
1158
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
1988
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
2340
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" />
1
9179
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,...
0
9116
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
8099
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 project—planning, coding, testing, and deployment—without 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
6702
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
6011
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
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3228
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
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.