Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have posted xml using c sharp the code given below but what if i have to post xsd schema like that

http://webservices.travelpack.com/xsd/external/FlightChoice.xsd[^]


here is its content that i want to post SO KINDLY TELL ME HOW TO POST XSD SCHEMA IS IT SIMILAR LIKE XML POST?

XML
<xs:complexType>
 <xs:sequence>
  <xs:element type="Source" name="Source"/>
   <xs:element type="AgentId" name="AgentId" minOccurs="0"/>
   <xs:element type="Password" name="Password" minOccurs="0"/>
   <xs:element type="SessionId" name="SessionId"/>
   <xs:element type="ClearBasket" name="ClearBasket" minOccurs="0"/>
   <xs:element type="ItemReference" name="ItemRef"/>
   <xs:element type="Item" name="OutAvail"/>
  <xs:element type="Item" name="InbAvail" minOccurs="0"/>
 </xs:sequence>
</xs:complexType>



and what i have posted is that

XML
<Request>
   <FlightSearch>
   <Source>0</Source>
   <AgentId>0</AgentId>
   <Password>0=</Password>
    <From>lhr</From>
    <To>lhe</To>
    <RetFrom />
    <RetTo />
    <Journey>R</Journey>
    <Direct />
    <Availability>O</Availability>
   </FlightSearch>
 </Request>


What I have tried:

C#
  public string postXMLData(string destinationUrl, XDocument requestXml)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(destinationUrl);
            byte[] bytes;
            bytes = Encoding.UTF8.GetBytes(requestXml.ToString());
            request.ContentType = "text/xml";
            request.ContentLength = bytes.Length;
            request.Method = "POST";
            Stream requestStream = request.GetRequestStream();
            requestStream.Write(bytes, 0, bytes.Length);
            requestStream.Close();
            HttpWebResponse response;
            response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream responseStream = response.GetResponseStream();
                string responseStr = new StreamReader(responseStream).ReadToEnd();
             }

         }
Posted
Updated 26-May-16 14:21pm
Comments
Sergey Alexandrovich Kryukov 26-May-16 23:17pm    
Not "similar". XSD is XML.
—SA

1 solution

An XML schema (XSD) IS an XML file by definition, so you can treat it in the same way as a regular XML file containing data elements.
See XML Schema Tutorial[^]

You might want to tell the receiver that you are sending a schema instead of content.
You can do this with, for example, an integer where the value 1 means content and 2 means schema, or what ever suits your needs.

It is of course possible to auto detect what kind of file it is, but it is usually better to be clear about what you are sending.
Auto detection could be an option if you can't change the communication protocol.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 26-May-16 23:18pm    
5ed. (Hard to explain such things, right?)
—SA
George Jonsson 27-May-16 2:12am    
Especially when you don't know if there any limitations or restrictions that can mess up the design.
Thanks for the upvote.
AIR TRAVELS 27-May-16 9:33am    
CAN XSD BE CONVERTED INTO XML AND THE POSTED USING ONLINE CONVERTER http://xsd2xml.com/
George Jonsson 27-May-16 10:01am    
XSD is an XML format.
Do you want to transfer the XSD schema or the XML file that is based on the schema?
AIR TRAVELS 1-Jun-16 11:08am    
well xsd converted to xml then posted xsd is only a defination of xml schema so it cannot be directly posted answer is this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900