3.6 Submit Files (XML) Examples

Data from an XML document is be consumed by the Web service method GetRandom. Following is a fragment from the WSDL file containing the XML schema for the GetRandom method.

 <?xml version="1.0" encoding="utf-8" ?> 
 <wsdl:definitions xmlns:s1="http://microsoft.com/wsdl/types/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:i0="http://tempuri.org/twrSchema.xsd" xmlns:tns="http://webserviceserver/Everett" targetNamespace="http://webserviceserver/Everett" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
     <wsdl:import namespace="http://tempuri.org/twrSchema.xsd" location="http://webserviceserver/anon/Service1.asmx?schema=typedDataSet" /> 
     <wsdl:types>
         <s:schema elementFormDefault="qualified" targetNamespace="http://webserviceserver/Everett">
             <s:import namespace="http://tempuri.org/twrSchema.xsd" /> 
             <s:import namespace="http://www.w3.org/2001/XMLSchema" /> 
             <s:import namespace="http://microsoft.com/wsdl/types/" />
             <s:element name="GetRandom">
                 <s:complexType>
                     <s:sequence>
                         <s:element minOccurs="1" maxOccurs="1" name="seed" type="s:int" /> 
                         <s:element minOccurs="1" maxOccurs="1" name="min" type="s:int" /> 
                         <s:element minOccurs="1" maxOccurs="1" name="max" type="s:int" /> 
                     </s:sequence>
                 </s:complexType>
             </s:element>
             <s:element name="GetRandomResponse">
                 <s:complexType>
                     <s:sequence>
                         <s:element minOccurs="1" maxOccurs="1" name="GetRandomResult" type="s:int" /> 
                     </s:sequence>
                 </s:complexType>
             </s:element>
         </s:schema>
     </wsdl:types>
 </wsdl:definitions>
  

The following example is how a Submit.xml looks when using the GetRandom method.

 <dfs:myFields xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:tns="http://webserviceserver/Everett">
     <dfs:dataFields>
         <tns:GetRandom>
             <tns:seed></tns:seed>
             <tns:min></tns:min>
             <tns:max></tns:max>
         </tns:GetRandom>
     </dfs:dataFields>
 </dfs:myFields>

As specified before, Submit.xml can broadly be categorized into two parts

  • The first part is static and contains <dfs:myFields> and <dfs:dataFields>.

  • The second part is the template for the GetRandom Web service method based on the Web service’s WSDL.

The child of <dfs:dataFields> is <tns:GetRandom>, which is the template of the GetRandom method. The three parameters to this Web service method are <tns:seed>, <tns:min>, and <tns:max>. This subtree validates against the XML schema element <s:element name="GetRandom"> in the WSDL example.