473,322 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

There MUST be a better way...

After much futzing about with the XML/XSD for the
Search.Response, I had to resort to this...

PLEASE Tell me there is a better way!
private void ExecuteAQuery(string
strLookingForWhat)
{
// create the area service object
SearchWebService.QueryService
queryService = CreateSearchService();
const string keywordQueryTemplate
= "<?xml version=\"1.0\" encoding=\"utf-8\" ?><QueryPacket
xmlns=\"urn:Microsoft.Search.Query\" Revision=\"1000
\"><Query
domain=\"QDomain\"><SupportedFormats><Format>urn:M icrosoft.
Search.Response.Document.Document</Format></SupportedFormat
s><Context><QueryText language=\"en-US\"
type=\"STRING\">query_text_placeholder</QueryText></Context
</Query></QueryPacket>";

const string SQLQueryTemplate
= "<?xml version=\"1.0\" encoding=\"utf-8\" ?><QueryPacket
xmlns=\"urn:Microsoft.Search.Query\" Revision=\"1000
\"><Query domain=\"s2003e:81
\"><SupportedFormats><Format>urn:Microsoft.Search. Response.
Document.Document</Format></SupportedFormats><Context><Quer
yText language=\"en-US\"
type=\"MSSQLFT\">query_text_placeholder</QueryText></Contex
t><Range><StartAt>1</StartAt><Count>5</Count></Range></Quer
y></QueryPacket>";
string queryString =
keywordQueryTemplate.Replace("query_text_placehold er",
strLookingForWhat);
// DOES NOT WORK (Internal System
Error Returned):
string queryString2 =
SQLQueryTemplate.Replace("query_text_placeholder",
strLookingForWhat);
// Init results:
string queryResults = null;
try
{
queryResults =
queryService.Query(queryString);
}
catch (Exception ExSheesh)
{
throw (ExSheesh);
}
//
// Load the returned XML into a
Document - first create a New XML Document,
// apply the Response.XSD schema,
then load the XML from the text received:
//
XmlDataDocument NewXmlDoc = new
XmlDataDocument();
// Causes error:
//NewXmlDoc.DataSet.ReadXmlSchema
("e:\\SPSSites\\SPSLive\\Response.xsd");
//NewXmlDoc.DataSet.ReadXmlSchema
("/Response.xsd");
NewXmlDoc.LoadXml(queryResults);
string XmlDocTableName =
NewXmlDoc.NameTable.ToString();
//
// Get the status:
//
XmlNodeList
Response_StatusNodeList = NewXmlDoc.GetElementsByTagName
("Status");
string ActualStatus =
Response_StatusNodeList[0].ChildNodes[0].Value;

XmlElement TheRootElement =
NewXmlDoc.DocumentElement;

XmlNodeList RangeNodeReference =
NewXmlDoc.GetElementsByTagName("Range");
XmlNodeList
RangeNodeContentsReference = RangeNodeReference
[0].ChildNodes;

DataSet PsuedoResultsDS = new
DataSet();
DataTable PsuedoResultsTable = new
DataTable("SearchResults");
//
// Add the columns:
//
DataColumn PRTitle = new DataColumn
("Title",System.Type.GetType("System.String"));
DataColumn PRLinkUrl = new
DataColumn("LinkUrl",System.Type.GetType("System.S tring"));
DataColumn PRFileExt = new
DataColumn("FileExt",System.Type.GetType("System.S tring"));
DataColumn PRDescription = new
DataColumn("Description",System.Type.GetType
("System.String"));
DataColumn PRFileDate = new
DataColumn("FileDate",System.Type.GetType
("System.DateTime"));
PsuedoResultsTable.Columns.Add
(PRTitle);
PsuedoResultsTable.Columns.Add
(PRLinkUrl);
PsuedoResultsTable.Columns.Add
(PRFileExt);
PsuedoResultsTable.Columns.Add
(PRDescription);
PsuedoResultsTable.Columns.Add
(PRFileDate);

PsuedoResultsDS.Tables.Add
(PsuedoResultsTable);
//
// Now check the nodes within
<Range> looking for the result set <Results>:
//
string sTotalItemsReturned = "";
int iTotalItemsReturned = 0;
//
foreach(XmlNode ARangeNode in
RangeNodeContentsReference)
{
if(ARangeNode.Name
== "StartAt")
{
}
if(ARangeNode.Name
== "Count")
{
}
//
// When we find the
<TotalAvailable> node, this tells us how many rows we have
// to process:
//
if(ARangeNode.Name
== "TotalAvailable")
{
//
// Now get how
many were returned (in <Range><TotalAvailable>) and
// convert it to
use for an index:
//
XmlNodeList
TotalValNode = NewXmlDoc.GetElementsByTagName
("TotalAvailable");

sTotalItemsReturned = TotalValNode[0].ChildNodes
[0].InnerText;
if
(sTotalItemsReturned != "")
{

iTotalItemsReturned = Convert.ToInt32
(sTotalItemsReturned);
}
}
//
// When we find the
<Results> node (should be right after TotalAvailable),
// our results are in the
nodes below:
//
if(ARangeNode.Name
== "Results")
{
//
// Get a pointer
to the Row:
//
XmlNodeList
ResultRowNodes = ARangeNode.ChildNodes;
XmlElement
TheActualResultRecord = (XmlElement)ResultRowNodes[0];
//
// Make sure we
got something:
//
if
(iTotalItemsReturned > 0)
{
//
// We did -
each now represents a Row - pull the data out and put
// it into
a new record to save to the dataset:
//
for (int
x=0; x < iTotalItemsReturned; x++)
{

XmlNodeList ColumnsNodes =
TheActualResultRecord.ChildNodes;

DataRow NewDataRow = PsuedoResultsDS.Tables
["SearchResults"].NewRow();

NewDataRow["Title"] = ColumnsNodes[0].InnerText;

string T0 = ColumnsNodes[0].Name;

string T1 = ColumnsNodes[0].InnerText;

NewDataRow["LinkUrl"] = ColumnsNodes[1].ChildNodes
[0].InnerText;

string T2 = ColumnsNodes[1].ChildNodes
[0].InnerText;

NewDataRow["FileExt"] = ColumnsNodes[1].ChildNodes
[0].Attributes[0].InnerText;

string T3 = ColumnsNodes[1].ChildNodes
[0].Attributes[0].InnerText;

NewDataRow["Description"] = ColumnsNodes
[2].InnerText;

string T4 = ColumnsNodes[2].InnerText;

NewDataRow["FileDate"] = Convert.ToDateTime
(ColumnsNodes[3].InnerText);
//
//
Add the new row:
//

PsuedoResultsDS.Tables["SearchResults"].Rows.Add
(NewDataRow);
}
}

}

}
dataGrid1.DataSource =
PsuedoResultsDS;
dataGrid1.SetDataBinding
(PsuedoResultsDS,"SearchResults");
}
Nov 12 '05 #1
22 2789
that code makes my eyes hurt. Can you tell me what is the problem, in
english?
-D

"David Sterling" <da************@sterling-consulting.com> wrote in message
news:1c*****************************@phx.gbl...
After much futzing about with the XML/XSD for the
Search.Response, I had to resort to this...

PLEASE Tell me there is a better way!
private void ExecuteAQuery(string
strLookingForWhat)
{
// lots and lots of code here.
}

Nov 12 '05 #2
that code makes my eyes hurt. Can you tell me what is the problem, in
english?
-D

"David Sterling" <da************@sterling-consulting.com> wrote in message
news:1c*****************************@phx.gbl...
After much futzing about with the XML/XSD for the
Search.Response, I had to resort to this...

PLEASE Tell me there is a better way!
private void ExecuteAQuery(string
strLookingForWhat)
{
// lots and lots of code here.
}

Nov 12 '05 #3
Yeah, basically this:

I'm getting back the Response from a query to a search service. I have
an inner data set (results) that I want; I have tried and tried to find
the correct way to map the XSD to no avail - (including using a
DataSet).

Alternative: I manually traverse through the XML Nodes until I find the
Results, then loop through and move the data items into a data set.

Gotta be a much better way!

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4
Yeah, basically this:

I'm getting back the Response from a query to a search service. I have
an inner data set (results) that I want; I have tried and tried to find
the correct way to map the XSD to no avail - (including using a
DataSet).

Alternative: I manually traverse through the XML Nodes until I find the
Results, then loop through and move the data items into a data set.

Gotta be a much better way!

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5
Yeah, basically this:

I'm getting back the Response from a query to a search service. I have
an inner data set (results) that I want; I have tried and tried to find
the correct way to map the XSD to no avail - (including using a
DataSet).

Alternative: I manually traverse through the XML Nodes until I find the
Results, then loop through and move the data items into a data set.

Gotta be a much better way!

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #6
Yeah, basically this:

I'm getting back the Response from a query to a search service. I have
an inner data set (results) that I want; I have tried and tried to find
the correct way to map the XSD to no avail - (including using a
DataSet).

Alternative: I manually traverse through the XML Nodes until I find the
Results, then loop through and move the data items into a data set.

Gotta be a much better way!

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #7
ok, you are getting a respoonse from a service.
The response is a System.Data.DataSet? is that right?

eg, in the client side you do something like this:
System.Data.DataSet ds= svc.MethodCall();

and in the server side you do somehting like this:
[WebMethod] public DataSet MethodCall() {
DataSet ds= new DataSet();
ds.Fill(...);
return ds;
}

And you are trying to get that Dataset to do ...what, exactly ?

I see that you have resorted to manually parsing the XML, and I understand
why you want to avoid doing this.

But I don't understand what works and what does not work? and just why you
have to manually parse it?

-D
"David Sterling" <da************@sterling-consulting.com> wrote in message
news:ey*************@TK2MSFTNGP11.phx.gbl...
Yeah, basically this:

I'm getting back the Response from a query to a search service. I have
an inner data set (results) that I want; I have tried and tried to find
the correct way to map the XSD to no avail - (including using a
DataSet).

Alternative: I manually traverse through the XML Nodes until I find the
Results, then loop through and move the data items into a data set.

Gotta be a much better way!

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #8
ok, you are getting a respoonse from a service.
The response is a System.Data.DataSet? is that right?

eg, in the client side you do something like this:
System.Data.DataSet ds= svc.MethodCall();

and in the server side you do somehting like this:
[WebMethod] public DataSet MethodCall() {
DataSet ds= new DataSet();
ds.Fill(...);
return ds;
}

And you are trying to get that Dataset to do ...what, exactly ?

I see that you have resorted to manually parsing the XML, and I understand
why you want to avoid doing this.

But I don't understand what works and what does not work? and just why you
have to manually parse it?

-D
"David Sterling" <da************@sterling-consulting.com> wrote in message
news:ey*************@TK2MSFTNGP11.phx.gbl...
Yeah, basically this:

I'm getting back the Response from a query to a search service. I have
an inner data set (results) that I want; I have tried and tried to find
the correct way to map the XSD to no avail - (including using a
DataSet).

Alternative: I manually traverse through the XML Nodes until I find the
Results, then loop through and move the data items into a data set.

Gotta be a much better way!

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #9
I am trying to use the Results as a feed for creating data for a
DataGrid to use for other purposes.

If I could get a DataSet out of Response I'd glady use that, however, I
cannot apply even the MS provided XSD. And thanks, there is no
documentation (other than the schema - lite reading for sure) regarding
this or even use of the search.

Only way I figured out the way I did it was by trial and error and code
snippets I'd found along the way - the various books I have from MS and
the half mil worth of others from Wrox, etc. show none of this. 2 days
to get to that as it is...(and they wonder why we get to hating
development!) - used to be you'd have to figure out the logic - now you
fumble around in the dark for days to get what should take 20 minutes to
do...

The

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #10
I am trying to use the Results as a feed for creating data for a
DataGrid to use for other purposes.

If I could get a DataSet out of Response I'd glady use that, however, I
cannot apply even the MS provided XSD. And thanks, there is no
documentation (other than the schema - lite reading for sure) regarding
this or even use of the search.

Only way I figured out the way I did it was by trial and error and code
snippets I'd found along the way - the various books I have from MS and
the half mil worth of others from Wrox, etc. show none of this. 2 days
to get to that as it is...(and they wonder why we get to hating
development!) - used to be you'd have to figure out the logic - now you
fumble around in the dark for days to get what should take 20 minutes to
do...

The

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #11
TO clarify as well...

The results I am getting are from using the SPS Search service - this
produces XML (not a dataset) from Microsoft.Search.Response using
QueryService. Thus why I tried to load the XML Doc and apply XSD to it
(catastrophic error).
David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #12
TO clarify as well...

The results I am getting are from using the SPS Search service - this
produces XML (not a dataset) from Microsoft.Search.Response using
QueryService. Thus why I tried to load the XML Doc and apply XSD to it
(catastrophic error).
David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #13
I can understand your frustration.

I don't know SPS Search service, but I think I get the idea.
Can you send me some example XML from a reasonable search?

You can try to manually build a DataSet but that may not be worthwhile if
all you want is to display it. You are aware that you can also bind an array
of objects to the datagrid and display the values of the properties ? It
may be much simpler for you.

-D
"David Sterling" <da************@sterling-consulting.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
I am trying to use the Results as a feed for creating data for a
DataGrid to use for other purposes.

If I could get a DataSet out of Response I'd glady use that, however, I
cannot apply even the MS provided XSD. And thanks, there is no
documentation (other than the schema - lite reading for sure) regarding
this or even use of the search.

Only way I figured out the way I did it was by trial and error and code
snippets I'd found along the way - the various books I have from MS and
the half mil worth of others from Wrox, etc. show none of this. 2 days
to get to that as it is...(and they wonder why we get to hating
development!) - used to be you'd have to figure out the logic - now you
fumble around in the dark for days to get what should take 20 minutes to
do...

The

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #14
I can understand your frustration.

I don't know SPS Search service, but I think I get the idea.
Can you send me some example XML from a reasonable search?

You can try to manually build a DataSet but that may not be worthwhile if
all you want is to display it. You are aware that you can also bind an array
of objects to the datagrid and display the values of the properties ? It
may be much simpler for you.

-D
"David Sterling" <da************@sterling-consulting.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
I am trying to use the Results as a feed for creating data for a
DataGrid to use for other purposes.

If I could get a DataSet out of Response I'd glady use that, however, I
cannot apply even the MS provided XSD. And thanks, there is no
documentation (other than the schema - lite reading for sure) regarding
this or even use of the search.

Only way I figured out the way I did it was by trial and error and code
snippets I'd found along the way - the various books I have from MS and
the half mil worth of others from Wrox, etc. show none of this. 2 days
to get to that as it is...(and they wonder why we get to hating
development!) - used to be you'd have to figure out the logic - now you
fumble around in the dark for days to get what should take 20 minutes to
do...

The

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #15
Sure...

Again, this is a response from the queryService using an XML query - the
returned XML looks like this:

<?xml version=\"1.0\" encoding=\"utf-16\"?>\n <ResponsePacket
xmlns=\"urn:Microsoft.Search.Response\">\n
<Response domain=\"QDomain\">\n
<Copyright>Microsoft (c) Office
SharePoint (tm) Portal Server 2003</Copyright>\n
<Range>\n
<StartAt>1</StartAt>\n
<Count>1000</Count>\n
<TotalAvailable>2</TotalAvailable>\n
<Results>\n
<Document type=\"Portal content\" relevance=\"2\"
xmlns=\"urn:Microsoft.Search.Response.Document\">\ n
<Title>Microsoft SharePoint Products and Technologies Web
site</Title>\n
<Action>\n
<LinkUrl
size=\"0\">http://s2003e:81/moreinfo.aspx?ID=92...-4553-9A2B-208
FB4E9D5F9&amp;TargetUrl=http://r.office.microsoft.com/r/rlidMsSharePoint
?clid=en-us</LinkUrl>\n
</Action>\n
<Description>Microsoft SharePoint Products and Technologies home
page</Description>\n
<Date>2004-03-18T23:00:20</Date>\n
</Document>\n
<Document type=\"Portal content\" relevance=\"2\"
xmlns=\"urn:Microsoft.Search.Response.Document\">\ n
<Title>Listing 1</Title>\n
<Action>\n
<LinkUrl fileExt=\"aspx\"
size=\"0\">http://s2003e:81/moreinfo.aspx?ID=5D...-4F91-BA3E-B2A
9CF3B87C9&amp;TargetUrl=http://s2003e:81/txtlstvw.aspx?LstID=5db56241-d4
58-4f91-ba3e-b2a9cf3b87c9</LinkUrl>\n
</Action>\n
<Description>\n </Description>\n
<Date>2004-03-18T23:00:20</Date>\n
</Document>
</Results>\n
</Range>\n
<Status>SUCCESS</Status>\n
</Response>\n
</ResponsePacket>

Note: The \n is in the response.

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #16
Sure...

Again, this is a response from the queryService using an XML query - the
returned XML looks like this:

<?xml version=\"1.0\" encoding=\"utf-16\"?>\n <ResponsePacket
xmlns=\"urn:Microsoft.Search.Response\">\n
<Response domain=\"QDomain\">\n
<Copyright>Microsoft (c) Office
SharePoint (tm) Portal Server 2003</Copyright>\n
<Range>\n
<StartAt>1</StartAt>\n
<Count>1000</Count>\n
<TotalAvailable>2</TotalAvailable>\n
<Results>\n
<Document type=\"Portal content\" relevance=\"2\"
xmlns=\"urn:Microsoft.Search.Response.Document\">\ n
<Title>Microsoft SharePoint Products and Technologies Web
site</Title>\n
<Action>\n
<LinkUrl
size=\"0\">http://s2003e:81/moreinfo.aspx?ID=92...-4553-9A2B-208
FB4E9D5F9&amp;TargetUrl=http://r.office.microsoft.com/r/rlidMsSharePoint
?clid=en-us</LinkUrl>\n
</Action>\n
<Description>Microsoft SharePoint Products and Technologies home
page</Description>\n
<Date>2004-03-18T23:00:20</Date>\n
</Document>\n
<Document type=\"Portal content\" relevance=\"2\"
xmlns=\"urn:Microsoft.Search.Response.Document\">\ n
<Title>Listing 1</Title>\n
<Action>\n
<LinkUrl fileExt=\"aspx\"
size=\"0\">http://s2003e:81/moreinfo.aspx?ID=5D...-4F91-BA3E-B2A
9CF3B87C9&amp;TargetUrl=http://s2003e:81/txtlstvw.aspx?LstID=5db56241-d4
58-4f91-ba3e-b2a9cf3b87c9</LinkUrl>\n
</Action>\n
<Description>\n </Description>\n
<Date>2004-03-18T23:00:20</Date>\n
</Document>
</Results>\n
</Range>\n
<Status>SUCCESS</Status>\n
</Response>\n
</ResponsePacket>

Note: The \n is in the response.

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #17
One other thing: The goal is not to use a Dataset per se; what I am
using this for is to locate documents by the URL; using the consolidated
list (the response), the user can select items to be moved off for
archive - best done through a DataGrid.

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #18
One other thing: The goal is not to use a Dataset per se; what I am
using this for is to locate documents by the URL; using the consolidated
list (the response), the user can select items to be moved off for
archive - best done through a DataGrid.

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #19
Ok, here's what I did and it seems to get pretty close without too much
effort.

1. go to msdn to get the various schema, there are 4:

Response
http://msdn.microsoft.com/library/en...sdResponse.asp

Response.Document
http://msdn.microsoft.com/library/en...seDocument.asp

Types
http://msdn.microsoft.com/library/en...rsxsdTypes.asp

You may also need Response Content, Response Form (depending on what your
queries return). eg
http://msdn.microsoft.com/library/en...nseContent.asp
http://msdn.microsoft.com/library/en...sponseForm.asp

Save each of these schema to a separate XSD file .

----
2.
modify the Response schema. The Response schema "Results" field is typed as
"anything" (xsd:any). But if you are doing sharepoint searches, it will
likely be a combination of Document, Content, and Form. The sample you
showed me had 2 results, both were documents. Your other queries may return
something else.

In any case I replaced this:
<xsd:complexType name="ResultCollectionType">
<xsd:annotation>
<xsd:documentation>Defines a set of results, in any format
supported.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:any namespace="##other">
<xsd:annotation>
<xsd:documentation>Any element in another namespace. Elements here
will be in any results format supported by the client. Office will support
the Form, Document, and Content results types.</xsd:documentation>
</xsd:annotation>
</xsd:any>
</xsd:choice>
</xsd:complexType>
with this:

<xsd:complexType name="ResultCollectionType">
<xsd:annotation>
<xsd:documentation>Defines a set of results, in any format
supported.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="doc:Document" />
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="content:Content" />
</xsd:choice>
</xsd:complexType>
and saved that doc to Microsoft.Search.Response-Modified.xsd
----
3. generate classes that correspond to this schema using the xsd.exe
utility. here's what I did:

xsd.exe /namespace:sps /c Microsoft.Search.Response-Modified.xsd
Microsoft.Search.Response.Document.xsd Microsoft.Search.Types.xsd
Microsoft.Search.Response.Content.xsd

(the above all on one line)

This produces a source file that has a really really long name. I renamed
it to (ResponsePacket.cs)

----
4.
You can now de-serialize directly from the stream, or from a file as shown
here:
sps.ResponsePacket packet;
string path = "Response-Pretty.xml";
XmlSerializer s1 = new XmlSerializer(typeof(sps.ResponsePacket));
System.IO.FileStream fs = new System.IO.FileStream(path,
System.IO.FileMode.Open);
packet= (sps.ResponsePacket) s1.Deserialize(fs);

----
5. accessing the fields is done like this

System.Console.WriteLine("Response Packet contains {0} Items ",
packet.Response.Length);
for (int i=0; i < packet.Response.Length; i++) {
System.Console.WriteLine("Item {0}: ", i);
System.Console.WriteLine(" Copyright: {0}",
packet.Response[i].Copyright);
System.Console.WriteLine(" Status: {0}",
packet.Response[i].Status);
System.Console.WriteLine(" domain: {0}",
packet.Response[i].domain);
if (packet.Response[i].Range!= null) {
System.Console.WriteLine(" Range: ( {0} items)",
packet.Response[i].Range.Length);
for (int j=0; j < packet.Response[i].Range.Length; j++) {
System.Console.WriteLine(" Item: {0}", j);
System.Console.WriteLine(" StartAt: {0}",
packet.Response[i].Range[j].StartAt);
System.Console.WriteLine(" Count: {0}",
packet.Response[i].Range[j].Count);
System.Console.WriteLine(" TotalAvailable: {0}",
packet.Response[i].Range[j].TotalAvailable);
if (null != packet.Response[i].Range[j].Results) {
System.Console.WriteLine(" Results: ({0} items)",
packet.Response[i].Range[j].Results.Length);

for (int k=0; k < packet.Response[i].Range[j].Results.Length;
k++) {
System.Console.WriteLine(" Item: {0}", k);
if (packet.Response[i].Range[j].Results[k] is sps.Document)

ShowDocument((sps.Document)packet.Response[i].Range[j].Results[k]); //
shows Title, relevance, Date, etc
else if (packet.Response[i].Range[j].Results[k] is
sps.Content)

ShowContent((sps.Content)packet.Response[i].Range[j].Results[k]); //
similar
}
}
}
}
}

----
6.
What you want to do is, I think, bind the list of Documents
(packet.Response[i].Range[j].Results ) to a DataGrid. The problem is that
objects in an array must have public properties if they are to be bound to a
DataGrid. And the generated code for the Document type does not expose
public properties.

See this article
http://msdn.microsoft.com/library/en...ml01202003.asp , about
30% down, for a brief discussion for how to work around this.

-Dino

"David Sterling" <da************@sterling-consulting.com> wrote in message
news:On**************@TK2MSFTNGP09.phx.gbl...
One other thing: The goal is not to use a Dataset per se; what I am
using this for is to locate documents by the URL; using the consolidated
list (the response), the user can select items to be moved off for
archive - best done through a DataGrid.

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #20
Ok, here's what I did and it seems to get pretty close without too much
effort.

1. go to msdn to get the various schema, there are 4:

Response
http://msdn.microsoft.com/library/en...sdResponse.asp

Response.Document
http://msdn.microsoft.com/library/en...seDocument.asp

Types
http://msdn.microsoft.com/library/en...rsxsdTypes.asp

You may also need Response Content, Response Form (depending on what your
queries return). eg
http://msdn.microsoft.com/library/en...nseContent.asp
http://msdn.microsoft.com/library/en...sponseForm.asp

Save each of these schema to a separate XSD file .

----
2.
modify the Response schema. The Response schema "Results" field is typed as
"anything" (xsd:any). But if you are doing sharepoint searches, it will
likely be a combination of Document, Content, and Form. The sample you
showed me had 2 results, both were documents. Your other queries may return
something else.

In any case I replaced this:
<xsd:complexType name="ResultCollectionType">
<xsd:annotation>
<xsd:documentation>Defines a set of results, in any format
supported.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:any namespace="##other">
<xsd:annotation>
<xsd:documentation>Any element in another namespace. Elements here
will be in any results format supported by the client. Office will support
the Form, Document, and Content results types.</xsd:documentation>
</xsd:annotation>
</xsd:any>
</xsd:choice>
</xsd:complexType>
with this:

<xsd:complexType name="ResultCollectionType">
<xsd:annotation>
<xsd:documentation>Defines a set of results, in any format
supported.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="doc:Document" />
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="content:Content" />
</xsd:choice>
</xsd:complexType>
and saved that doc to Microsoft.Search.Response-Modified.xsd
----
3. generate classes that correspond to this schema using the xsd.exe
utility. here's what I did:

xsd.exe /namespace:sps /c Microsoft.Search.Response-Modified.xsd
Microsoft.Search.Response.Document.xsd Microsoft.Search.Types.xsd
Microsoft.Search.Response.Content.xsd

(the above all on one line)

This produces a source file that has a really really long name. I renamed
it to (ResponsePacket.cs)

----
4.
You can now de-serialize directly from the stream, or from a file as shown
here:
sps.ResponsePacket packet;
string path = "Response-Pretty.xml";
XmlSerializer s1 = new XmlSerializer(typeof(sps.ResponsePacket));
System.IO.FileStream fs = new System.IO.FileStream(path,
System.IO.FileMode.Open);
packet= (sps.ResponsePacket) s1.Deserialize(fs);

----
5. accessing the fields is done like this

System.Console.WriteLine("Response Packet contains {0} Items ",
packet.Response.Length);
for (int i=0; i < packet.Response.Length; i++) {
System.Console.WriteLine("Item {0}: ", i);
System.Console.WriteLine(" Copyright: {0}",
packet.Response[i].Copyright);
System.Console.WriteLine(" Status: {0}",
packet.Response[i].Status);
System.Console.WriteLine(" domain: {0}",
packet.Response[i].domain);
if (packet.Response[i].Range!= null) {
System.Console.WriteLine(" Range: ( {0} items)",
packet.Response[i].Range.Length);
for (int j=0; j < packet.Response[i].Range.Length; j++) {
System.Console.WriteLine(" Item: {0}", j);
System.Console.WriteLine(" StartAt: {0}",
packet.Response[i].Range[j].StartAt);
System.Console.WriteLine(" Count: {0}",
packet.Response[i].Range[j].Count);
System.Console.WriteLine(" TotalAvailable: {0}",
packet.Response[i].Range[j].TotalAvailable);
if (null != packet.Response[i].Range[j].Results) {
System.Console.WriteLine(" Results: ({0} items)",
packet.Response[i].Range[j].Results.Length);

for (int k=0; k < packet.Response[i].Range[j].Results.Length;
k++) {
System.Console.WriteLine(" Item: {0}", k);
if (packet.Response[i].Range[j].Results[k] is sps.Document)

ShowDocument((sps.Document)packet.Response[i].Range[j].Results[k]); //
shows Title, relevance, Date, etc
else if (packet.Response[i].Range[j].Results[k] is
sps.Content)

ShowContent((sps.Content)packet.Response[i].Range[j].Results[k]); //
similar
}
}
}
}
}

----
6.
What you want to do is, I think, bind the list of Documents
(packet.Response[i].Range[j].Results ) to a DataGrid. The problem is that
objects in an array must have public properties if they are to be bound to a
DataGrid. And the generated code for the Document type does not expose
public properties.

See this article
http://msdn.microsoft.com/library/en...ml01202003.asp , about
30% down, for a brief discussion for how to work around this.

-Dino

"David Sterling" <da************@sterling-consulting.com> wrote in message
news:On**************@TK2MSFTNGP09.phx.gbl...
One other thing: The goal is not to use a Dataset per se; what I am
using this for is to locate documents by the URL; using the consolidated
list (the response), the user can select items to be moved off for
archive - best done through a DataGrid.

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #21
Instead of manually modifying the huge file that will be generated, you can
perform a search & replace in VS with regular a expression as explained in
http://weblogs.asp.net/cazzu/archive.../26/25460.aspx, and you'll get
all public properties and be ready to data bind to the DataGrid

--
Daniel Cazzulino [MVP XML]
Clarius Consulting SA
http://weblogs.asp.net/cazzu
http://aspnet2.com

"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
Ok, here's what I did and it seems to get pretty close without too much
effort.

1. go to msdn to get the various schema, there are 4:

Response
http://msdn.microsoft.com/library/en...sdResponse.asp

Response.Document
http://msdn.microsoft.com/library/en...seDocument.asp
Types
http://msdn.microsoft.com/library/en...rsxsdTypes.asp

You may also need Response Content, Response Form (depending on what your
queries return). eg
http://msdn.microsoft.com/library/en...nseContent.asp http://msdn.microsoft.com/library/en...sponseForm.asp

Save each of these schema to a separate XSD file .

----
2.
modify the Response schema. The Response schema "Results" field is typed as "anything" (xsd:any). But if you are doing sharepoint searches, it will
likely be a combination of Document, Content, and Form. The sample you
showed me had 2 results, both were documents. Your other queries may return something else.

In any case I replaced this:
<xsd:complexType name="ResultCollectionType">
<xsd:annotation>
<xsd:documentation>Defines a set of results, in any format
supported.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:any namespace="##other">
<xsd:annotation>
<xsd:documentation>Any element in another namespace. Elements here
will be in any results format supported by the client. Office will support the Form, Document, and Content results types.</xsd:documentation>
</xsd:annotation>
</xsd:any>
</xsd:choice>
</xsd:complexType>
with this:

<xsd:complexType name="ResultCollectionType">
<xsd:annotation>
<xsd:documentation>Defines a set of results, in any format
supported.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="doc:Document" />
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="content:Content" />
</xsd:choice>
</xsd:complexType>
and saved that doc to Microsoft.Search.Response-Modified.xsd
----
3. generate classes that correspond to this schema using the xsd.exe
utility. here's what I did:

xsd.exe /namespace:sps /c Microsoft.Search.Response-Modified.xsd
Microsoft.Search.Response.Document.xsd Microsoft.Search.Types.xsd
Microsoft.Search.Response.Content.xsd

(the above all on one line)

This produces a source file that has a really really long name. I renamed
it to (ResponsePacket.cs)

----
4.
You can now de-serialize directly from the stream, or from a file as shown
here:
sps.ResponsePacket packet;
string path = "Response-Pretty.xml";
XmlSerializer s1 = new XmlSerializer(typeof(sps.ResponsePacket));
System.IO.FileStream fs = new System.IO.FileStream(path,
System.IO.FileMode.Open);
packet= (sps.ResponsePacket) s1.Deserialize(fs);

----
5. accessing the fields is done like this

System.Console.WriteLine("Response Packet contains {0} Items ",
packet.Response.Length);
for (int i=0; i < packet.Response.Length; i++) {
System.Console.WriteLine("Item {0}: ", i);
System.Console.WriteLine(" Copyright: {0}",
packet.Response[i].Copyright);
System.Console.WriteLine(" Status: {0}",
packet.Response[i].Status);
System.Console.WriteLine(" domain: {0}",
packet.Response[i].domain);
if (packet.Response[i].Range!= null) {
System.Console.WriteLine(" Range: ( {0} items)",
packet.Response[i].Range.Length);
for (int j=0; j < packet.Response[i].Range.Length; j++) {
System.Console.WriteLine(" Item: {0}", j);
System.Console.WriteLine(" StartAt: {0}",
packet.Response[i].Range[j].StartAt);
System.Console.WriteLine(" Count: {0}",
packet.Response[i].Range[j].Count);
System.Console.WriteLine(" TotalAvailable: {0}",
packet.Response[i].Range[j].TotalAvailable);
if (null != packet.Response[i].Range[j].Results) {
System.Console.WriteLine(" Results: ({0} items)",
packet.Response[i].Range[j].Results.Length);

for (int k=0; k < packet.Response[i].Range[j].Results.Length; k++) {
System.Console.WriteLine(" Item: {0}", k);
if (packet.Response[i].Range[j].Results[k] is sps.Document)
ShowDocument((sps.Document)packet.Response[i].Range[j].Results[k]); //
shows Title, relevance, Date, etc
else if (packet.Response[i].Range[j].Results[k] is
sps.Content)

ShowContent((sps.Content)packet.Response[i].Range[j].Results[k]); //
similar
}
}
}
}
}

----
6.
What you want to do is, I think, bind the list of Documents
(packet.Response[i].Range[j].Results ) to a DataGrid. The problem is that objects in an array must have public properties if they are to be bound to a DataGrid. And the generated code for the Document type does not expose
public properties.

See this article
http://msdn.microsoft.com/library/en...ml01202003.asp , about 30% down, for a brief discussion for how to work around this.

-Dino

"David Sterling" <da************@sterling-consulting.com> wrote in message
news:On**************@TK2MSFTNGP09.phx.gbl...
One other thing: The goal is not to use a Dataset per se; what I am
using this for is to locate documents by the URL; using the consolidated
list (the response), the user can select items to be moved off for
archive - best done through a DataGrid.

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
Nov 12 '05 #22
Instead of manually modifying the huge file that will be generated, you can
perform a search & replace in VS with regular a expression as explained in
http://weblogs.asp.net/cazzu/archive.../26/25460.aspx, and you'll get
all public properties and be ready to data bind to the DataGrid

--
Daniel Cazzulino [MVP XML]
Clarius Consulting SA
http://weblogs.asp.net/cazzu
http://aspnet2.com

"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
Ok, here's what I did and it seems to get pretty close without too much
effort.

1. go to msdn to get the various schema, there are 4:

Response
http://msdn.microsoft.com/library/en...sdResponse.asp

Response.Document
http://msdn.microsoft.com/library/en...seDocument.asp
Types
http://msdn.microsoft.com/library/en...rsxsdTypes.asp

You may also need Response Content, Response Form (depending on what your
queries return). eg
http://msdn.microsoft.com/library/en...nseContent.asp http://msdn.microsoft.com/library/en...sponseForm.asp

Save each of these schema to a separate XSD file .

----
2.
modify the Response schema. The Response schema "Results" field is typed as "anything" (xsd:any). But if you are doing sharepoint searches, it will
likely be a combination of Document, Content, and Form. The sample you
showed me had 2 results, both were documents. Your other queries may return something else.

In any case I replaced this:
<xsd:complexType name="ResultCollectionType">
<xsd:annotation>
<xsd:documentation>Defines a set of results, in any format
supported.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:any namespace="##other">
<xsd:annotation>
<xsd:documentation>Any element in another namespace. Elements here
will be in any results format supported by the client. Office will support the Form, Document, and Content results types.</xsd:documentation>
</xsd:annotation>
</xsd:any>
</xsd:choice>
</xsd:complexType>
with this:

<xsd:complexType name="ResultCollectionType">
<xsd:annotation>
<xsd:documentation>Defines a set of results, in any format
supported.</xsd:documentation>
</xsd:annotation>
<xsd:choice maxOccurs="unbounded">
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="doc:Document" />
<xsd:element minOccurs="0" maxOccurs="unbounded"
ref="content:Content" />
</xsd:choice>
</xsd:complexType>
and saved that doc to Microsoft.Search.Response-Modified.xsd
----
3. generate classes that correspond to this schema using the xsd.exe
utility. here's what I did:

xsd.exe /namespace:sps /c Microsoft.Search.Response-Modified.xsd
Microsoft.Search.Response.Document.xsd Microsoft.Search.Types.xsd
Microsoft.Search.Response.Content.xsd

(the above all on one line)

This produces a source file that has a really really long name. I renamed
it to (ResponsePacket.cs)

----
4.
You can now de-serialize directly from the stream, or from a file as shown
here:
sps.ResponsePacket packet;
string path = "Response-Pretty.xml";
XmlSerializer s1 = new XmlSerializer(typeof(sps.ResponsePacket));
System.IO.FileStream fs = new System.IO.FileStream(path,
System.IO.FileMode.Open);
packet= (sps.ResponsePacket) s1.Deserialize(fs);

----
5. accessing the fields is done like this

System.Console.WriteLine("Response Packet contains {0} Items ",
packet.Response.Length);
for (int i=0; i < packet.Response.Length; i++) {
System.Console.WriteLine("Item {0}: ", i);
System.Console.WriteLine(" Copyright: {0}",
packet.Response[i].Copyright);
System.Console.WriteLine(" Status: {0}",
packet.Response[i].Status);
System.Console.WriteLine(" domain: {0}",
packet.Response[i].domain);
if (packet.Response[i].Range!= null) {
System.Console.WriteLine(" Range: ( {0} items)",
packet.Response[i].Range.Length);
for (int j=0; j < packet.Response[i].Range.Length; j++) {
System.Console.WriteLine(" Item: {0}", j);
System.Console.WriteLine(" StartAt: {0}",
packet.Response[i].Range[j].StartAt);
System.Console.WriteLine(" Count: {0}",
packet.Response[i].Range[j].Count);
System.Console.WriteLine(" TotalAvailable: {0}",
packet.Response[i].Range[j].TotalAvailable);
if (null != packet.Response[i].Range[j].Results) {
System.Console.WriteLine(" Results: ({0} items)",
packet.Response[i].Range[j].Results.Length);

for (int k=0; k < packet.Response[i].Range[j].Results.Length; k++) {
System.Console.WriteLine(" Item: {0}", k);
if (packet.Response[i].Range[j].Results[k] is sps.Document)
ShowDocument((sps.Document)packet.Response[i].Range[j].Results[k]); //
shows Title, relevance, Date, etc
else if (packet.Response[i].Range[j].Results[k] is
sps.Content)

ShowContent((sps.Content)packet.Response[i].Range[j].Results[k]); //
similar
}
}
}
}
}

----
6.
What you want to do is, I think, bind the list of Documents
(packet.Response[i].Range[j].Results ) to a DataGrid. The problem is that objects in an array must have public properties if they are to be bound to a DataGrid. And the generated code for the Document type does not expose
public properties.

See this article
http://msdn.microsoft.com/library/en...ml01202003.asp , about 30% down, for a brief discussion for how to work around this.

-Dino

"David Sterling" <da************@sterling-consulting.com> wrote in message
news:On**************@TK2MSFTNGP09.phx.gbl...
One other thing: The goal is not to use a Dataset per se; what I am
using this for is to locate documents by the URL; using the consolidated
list (the response), the user can select items to be moved off for
archive - best done through a DataGrid.

David M. Sterling
CEO/Principal Consultant
Sterling International Consulting Group
da************@sterling-consulting.com
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
Nov 12 '05 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
6
by: Michael | last post by:
Hi, I'm fairly new at Python, and have the following code that works but isn't very concise, is there a better way of writing it?? It seems much more lengthy than python code i have read..... :-)...
1
by: Bob | last post by:
I need to know if there is a better way to construct this SQL statement. (Error handling is omitted) MS SQL Server 2000 Insert into FSSUTmp Select a.acct_no, a.ac_nm, a.ac_type, 10, -1, -1...
1
by: milkyway | last post by:
Hello, I am considering the following in order to accomplish my task. An application has to be created that runs from a regular computer as well as from a WAP-enabled device. When the user is...
19
by: Rhek | last post by:
Hello, I would like to apologize for double posting this question because I posted this same question in what looks like the VB 6 newgroups and not the .Net newsgroup... Here goes: The code...
6
by: Nick Dreyer | last post by:
In VB.NET I would like to not have to create property get/set procedures for every class variable I want to expose to Excel VBA projects in COM builds. Can anyone tell me if that is possible, or...
43
by: Rob R. Ainscough | last post by:
I realize I'm learning web development and there is a STEEP learning curve, but so far I've had to learn: HTML XML JavaScript ASP.NET using VB.NET ..NET Framework ADO.NET SSL
3
by: baibaichen | last post by:
hi i want to output strings with indent space, the code looks like: std::set<std::string> files; std::set<std::string> iterator b = files.begin(); std::set<std::string> iterator e =...
5
by: B1ackwater | last post by:
We've fooled around with Access a bit, but only using the single-user store-bought version. It seems to be a good database - versatile and infinitely programmable - and can apparently be used as a...
12
by: Dom | last post by:
VB had a "line" control, just a simple line that let you separate controls without the wasted space of a Groupbox. Did CSharp drop this? Dom
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.