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.Appen d("<?xml version=\"1.0\" ?>");
sbPayload.Appen d("<a:searchreq uest xmlns:a=\"DAV:\ ">");
sbPayload.Appen d("<sql> SELECT \"urn:schemas:c ontacts:fileas\ " ");
sbPayload.Appen d(", \"urn:schemas:c ontacts:givenNa me\" ");
sbPayload.Appen d(", \"urn:schemas:c ontacts:sn\" ");
sbPayload.Appen d(", \"urn:schemas:c ontacts:o\" ");
sbPayload.Appen d("FROM Scope('SHALLOW TRAVERSAL OF \"\"') ");
sbPayload.Appen d("Where \"DAV:isfolder\ " = false AND \"DAV:contentcl ass\"
");
sbPayload.Appen d("= 'urn:content-classes:person' ");
sbPayload.Appen d(" ORDER BY \"urn:schemas:c ontacts:fileas\ " ASC");
sbPayload.Appen d("</>");
sbPayload.Appen d("</>");
// Array to hold Xml Payload
byte[] arPayload = null;
try
{
// Get Payload and Encode it to utf-8
arPayload = Encoding.UTF8.G etBytes((string )sbPayload.ToSt ring());
// Create HTTP Web Request & Set Properties
HttpWebRequest oWebRequest =
(System.Net.Htt pWebRequest)Htt pWebRequest.Cre ate(sSourceURL) ;
oWebRequest.Met hod = "SEARCH";
oWebRequest.Con tentType = "text/xml";
oWebRequest.Con tentLength = arPayload.Lengt h;
// Inject the Search Payload into the RequestStream
Stream oRequestStream = oWebRequest.Get RequestStream() ;
oRequestStream. Write(arPayload , 0, arPayload.Lengt h);
oRequestStream. Close();
// Set Credentials to Access Exchange Store
oWebRequest.Cre dentials = CreateCredentia lCache(sSourceU RL);
// Create the Web Response Object
System.Net.WebR esponse oWebResponse = (System.Net.Web Response)
oWebRequest.Get Response();
// Get the Xml Response Stream
<jo*****@hotmai l.com> wrote in message
news:OX******** *****@TK2MSFTNG P09.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.Ge tResponseStream ();
StreamReader oStreamReader= new StreamReader(os tream);
string strXMLData=oStr eamReader.ReadT oEnd();
Thanks
"George Durzi" <gd****@hotmail .com> wrote in message
news:eE******** ******@TK2MSFTN GP10.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.Ge tResponseStream ();
Encoding oEncoding = System.Text.Enc oding.GetEncodi ng("utf=8");
StreamReader oStreamReader = new StreamReader(oS tream, oEncoding);
string sXmlData = oStreamReader.R eadToEnd();
<jo*****@hotmai l.com> wrote in message
news:eT******** ******@TK2MSFTN GP12.phx.gbl... I am receiving xml via tcp/ip and want to save it into a msmq queue.
when I use the StreamReader.Re adLine() it only reads one line of the
stream. but my xml could be more than 1 line.
when I use StreamReader.Re adToEnd() 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