Expose Schema for Webservice Result - InfoPath Dev
in

InfoPath Dev

Expose Schema for Webservice Result

Last post 04-13-2009 03:17 PM by JamieGr. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 04-13-2009 03:17 PM

    Expose Schema for Webservice Result

    Hi,

     

    I have creaated a webservice which works in internet explorer (i.e. it brings back the correct xml data). When I add it as a data connection to infopath there is nothing in the data tree under the "Results" node. I suspect this is because I have not assigned the schema to the xml document I am sending back.

    The service test page describes the webservice like this

    HTTP/1.1 200 OK
    Content-Type: text/xml; charset=utf-8
    Content-Length: length

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <GetSingleVersionResponse xmlns="http://barcap.org">
          <GetSingleVersionResult>xml</GetSingleVersionResult>
        </GetSingleVersionResponse>
      </soap:Body>
    </soap:Envelope>

     

    but you can see that      <GetSingleVersionResult>xml</GetSingleVersionResult> contains no schema information.

     

    The c# code i am using is a bit of a mess because i had to switch from returning a DataSet object to returning a XMLDocument object (this was a workaround for another problem). When it was returning a DataSet i could see the schema tree in the Data Source pannel. Here is the c# code:

    [WebMethod]public XmlDocument GetSingleVersion(string stTableName, string stItemGUID)

    {

    ///XmlDocument result = null;

    XmlDocument result = new XmlDocument();string stSchemaPath = @"F:\Visual Studio 2005\Projects\Project1\Schemas\Schema1.xsd";

     

    result.Schemas.Add(null, stSchemaPath);

    using (SqlConnection conn = new SqlConnection(sqlConn))

    {

    conn.Open();

    SqlCommand command = conn.CreateCommand();command.CommandText = @"

    SELECT XMLData

    FROM dbo." + stTableName + @"

    WHERE ItemGUID = @x";

    command.Parameters.Add("@x", SqlDbType.UniqueIdentifier);

    command.Parameters[0].Value = new Guid(stItemGUID);

    SqlDataReader reader = command.ExecuteReader();

    if (reader.Read())

    {

    DataSet ds = new DataSet();

    ds.ReadXmlSchema(stSchemaPath);

    XmlDataDocument xd = new XmlDataDocument(ds);

    xd.Schemas.Add(null, stSchemaPath);

    xd.Load(new StringReader((string)reader.GetValue(0)));

    result = xd;

    //result = xd.DataSet;

    }

    conn.Close();

    return result;

    }

    }

     

    Thanks for any suggestions.

     

    Jamie

     

     


     

     

     

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.