I didn't include that code coz I didn't think the content of the WebResponse
was relevant. I don't think it's applicable to what you're doing, but here
you go
StringBuilder sbPayload = new StringBuilder();
sbPayload.Append("<?xml version=\"1.0\"?>");
sbPayload.Append("<a:searchrequest xmlns:a=\"DAV:\">");
sbPayload.Append("<sql> SELECT \"urn:schemas:contacts:fileas\" ");
sbPayload.Append(", \"urn:schemas:contacts:givenName\" ");
sbPayload.Append(", \"urn:schemas:contacts:sn\" ");
sbPayload.Append(", \"urn:schemas:contacts:o\" ");
sbPayload.Append("FROM Scope('SHALLOW TRAVERSAL OF \"\"') ");
sbPayload.Append("Where \"DAV:isfolder\" = false AND \"DAV:contentclass\"
");
sbPayload.Append("= 'urn:content-classes:person'");
sbPayload.Append(" ORDER BY \"urn:schemas:contacts:fileas\" ASC");
sbPayload.Append("</>");
sbPayload.Append("</>");
// Array to hold Xml Payload
byte[] arPayload = null;
try
{
// Get Payload and Encode it to utf-8
arPayload = Encoding.UTF8.GetBytes((string)sbPayload.ToString( ));
// Create HTTP Web Request & Set Properties
HttpWebRequest oWebRequest =
(System.Net.HttpWebRequest)HttpWebRequest.Create(s SourceURL);
oWebRequest.Method = "SEARCH";
oWebRequest.ContentType = "text/xml";
oWebRequest.ContentLength = arPayload.Length;
// Inject the Search Payload into the RequestStream
Stream oRequestStream = oWebRequest.GetRequestStream();
oRequestStream.Write(arPayload, 0, arPayload.Length);
oRequestStream.Close();
// Set Credentials to Access Exchange Store
oWebRequest.Credentials = CreateCredentialCache(sSourceURL);
// Create the Web Response Object
System.Net.WebResponse oWebResponse = (System.Net.WebResponse)
oWebRequest.GetResponse();
// Get the Xml Response Stream
<jo*****@hotmail.com> wrote in message
news:OX*************@TK2MSFTNGP09.phx.gbl...
I am trying to use your code but i get an error on oWebresponse: use of
unassigned local variable:
WebResponse oWebResponse;
Stream ostream= oWebResponse.GetResponseStream();
StreamReader oStreamReader= new StreamReader(ostream);
string strXMLData=oStreamReader.ReadToEnd();
Thanks
"George Durzi" <gd****@hotmail.com> wrote in message
news:eE**************@TK2MSFTNGP10.phx.gbl... How are you constructing your StreamReader?
Are you using a WebResponse object?
In my code, I create a WebResponse object from a WebRequest object, I
then create my stream as follows
Stream oStream = oWebResponse.GetResponseStream();
Encoding oEncoding = System.Text.Encoding.GetEncoding("utf=8");
StreamReader oStreamReader = new StreamReader(oStream, oEncoding);
string sXmlData = oStreamReader.ReadToEnd();
<jo*****@hotmail.com> wrote in message
news:eT**************@TK2MSFTNGP12.phx.gbl... I am receiving xml via tcp/ip and want to save it into a msmq queue.
when I use the StreamReader.ReadLine() it only reads one line of the
stream. but my xml could be more than 1 line.
when I use StreamReader.ReadToEnd() it just listens to the port until
the connection is closed and then it writes it to the queue, which is not the method that i want because more than one xml are saved to a queue at a
time. basicly i need a read method that receives 1 xml that comes through
and saves it to the queue.
thanks in advance