Any tool that will make a Strongly Typed object from an XSD?

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,081
Programming Experience
10+
Hi

So, I'm pretty well up on datasets and the dataset generator, but time has come where I'm having to form XML requests and parse responses directly to/from a webserver. I'd like to know, given that I have the XSD for the request/response, whether there is some tool I can run to turn this into a block of code so i can say:

Dim x as New MyXMLRequest
x.Whatever = Value
x.Whatever.OtherTHing = ANotherValue

tcpSocket.Write(x.ToXML())



I've used a tool called XSD.exe to generate a dataset from the XSD, but the XML it forms isnt quite right..
 
Cool.. I've used the snips to get to the point where I serailize into a stringbuilder. The last point of note, is that the line:

ns.Add("", "")

Does indeed squish some(not all) of the namespace headers in the first tag, but every tag suddenly sprouts a q1: prefix:

VB.NET:
<q1:EXPERIAN xmlns:q1="http://tempuri.org/EseriesSchema.xsd">
  <q1:ESERIES>
    <q1:FORM_ID>AUTHENTICATE_PLUS</q1:FORM_ID>
  </q1:ESERIES>

Is it significant?
 
the q1: issue was:

XSD generated code
This code had numerous [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://tempuri.org/EseriesSchema.xsd")] directives
Commenting them all out made it possible to generate XML without any namespace prefixes

Attempting to serialize an object whose members have these attributes makes it impossible to remove the namespace declare entirely; the first time a member still having this attribute, is serialized, the namespace declare will appear
 
Cool.. I've used the snips to get to the point where I serailize into a stringbuilder.
For testing/verification purposes? You should be able to use the HttpWebRequest/Response and their Request-/ResponseStream to serialize to and from, or NetworkStream of the TcpClient (you indicated Socket in first post, a NetworkStream wrapped around the Socket makes a TcpClient)
but every tag suddenly sprouts a q1: prefix:
Is it significant?
Very crucial if the xml nodes actually belongs to that namespace, the xml of your post 3 didn't have this namespace, I used this to generate the xsd and class so mine did not qualify any node with a namespace prefix.
 
For testing/verification purposes? You should be able to use the HttpWebRequest/Response and their Request-/ResponseStream to serialize to and from, or NetworkStream of the TcpClient (you indicated Socket in first post, a NetworkStream wrapped around the Socket makes a TcpClient)
That part is as yet undertermined. I havent had any specs of how Experian's e-series server expects the info.. But testing-wise, yes.. it looks good so far! :)

I used this to generate the xsd and class so mine did not qualify any node with a namespace prefix.
Ah.. I generated the XSD in visual design mode.. it has a namespace directive.. :)
 
Back
Top