Hi Chris,
Thanks! (and thanks also for the rest of the comments/help).

Basically I ended up writing my own stream reader. I would detect the change
to handle the binary data, and character data. It was rather interesting,
but, at least I now have a stream reader that can change encodings. ;-)

Thanks again all.

Cheers!
Dave

----- Original Message -----
From: "Chris Day" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 08, 2004 11:48 PM
Subject: Re: [ADVANCED-DOTNET] parsing a java webservice


One thing you may want to try is that once you have gotten to the start
of the document pass the stream into a BinaryReader.  I've found that
StreamReaders really don't like binary data in the stream!

StreamReader sr = new StreamReader(someXmlStream);
// read through to word doc
BinaryReader br = new BinaryReader(sr.BaseStream);
byte[] buf = br.ReadBytes(length);

HTH
Chris

> -----Original Message-----
> From: dave wanta [mailto:[EMAIL PROTECTED]
> Sent: Saturday, 6 March 2004 1:50 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [ADVANCED-DOTNET] parsing a java webservice
>
> See, that's the problem.
>
> The doc IS NOT base64 encoded. It is raw binary. That's
> right. They just threw in binary data in the middle of this document.
>
> That's why I have to parse the response by hand. Its not even
> valid XML.
> Unfortunately, the service is provided by the gov't, so the
> way it is provided is totally out of my hands. (Don't ask me
> how/why it is built this way). Its like they threw in tags
> where ever they thought they wanted too.
> Then they said "oh btw, here is a binary doc, and its name is
> blah.doc. It ends at the start of the next tag".
>
> So, I parse the string, until I get to the start of the doc,
> then grab the sub string. But when I convert it back to
> binary ( Encoding.UTF8.GetBytes( docSubstring ) ), the data
> gets corrupt.
>
> hth,
> Dave
> PS: I guess the transport is the java webservice, grrr.., and
> the real problem I'm having is going byte[] --> string -->
> byte[] without corruption.
> I'm wondering if I need to build my own reader, so I can
> switch encodings on the fly.
>
>
>
>
> ----- Original Message -----
> From: "Streno, Robert" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, March 05, 2004 4:34 PM
> Subject: Re: [ADVANCED-DOTNET] parsing a java webservice
>
>
> > Why are you parsing the raw SOAP?  Why not make a call
> directly to the
> > web service using a proxy constructed from the WSDL for the
> web service?
> >
> > Once you do that, you should be able to reference the parameter as a
> string.
> > Assuming that the doc has been base64 encoded, it should be a
> > relatively simple task to write the individual bytes out to
> a disk file.
> >
> > -Rob
> >
> > -----Original Message-----
> > From: Moderated discussion of advanced .NET topics.
> > [mailto:[EMAIL PROTECTED] On Behalf Of dave wanta
> > Sent: Friday, March 05, 2004 11:44 AM
> > To: [EMAIL PROTECTED]
> > Subject: [ADVANCED-DOTNET] parsing a java webservice
> >
> >
> > Hi All,
> > Hopefully I can explain this one with out mucking this
> up.;-) I've got
> > to consume a Java webservice (which I know nothing about).
> >
> > A co-worker gave me the code that mades the Soap request, using a
> WebRequest
> > (only way we could get .NET to talk to the service successfully).
> > Which works great.
> >
> > So now I get the ResponseStream, which contains the Soap
> XML (of which
> > is embedded a binary word document). I need to parse the response
> > stream to find where the word document starts and ends, and
> extract it.
> >
> > So I'm reading the stream with a StreamReader, using
> Encoding.UTF8. I
> locate
> > where the word doc starts and stops in the string, and then covert
> > that substring back to a byte[], and save it. but the word doc gets
> > corrupt in the process. Are there any recommendations on how to
> > convert Stream --> String --> SubString --> Byte[] without
> > loosing/corrupting any of the
> data?
> >
> > If I go Stream --> byte[], and  manually locate the word doc ( I
> physically
> > counted the offset where the doc starts and ends), and then
> save that
> > sub array, everything works. Obviously, I can't do this in
> production,
> > but I verified the word doc is not corrupt.
> >
> > Any ideas?
> >
> > Thanks,
> > Dave
> >
> > ===================================
> > This list is hosted by DevelopMentor(r)
> http://www.develop.com Some
> > .NET courses you may be interested in:
> >
> > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
> > http://www.develop.com/courses/gaspdotnetls
> >
> > View archives and manage your subscription(s) at
> http://discuss.develop.com
> >
> > ===================================
> > This list is hosted by DevelopMentor(r)  http://www.develop.com Some

> > .NET courses you may be interested in:
> >
> > NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
> > http://www.develop.com/courses/gaspdotnetls
> >
> > View archives and manage your subscription(s) at
> http://discuss.develop.com
> >
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
> Some .NET courses you may be interested in:
>
> NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
> http://www.develop.com/courses/gaspdotnetls
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>
>

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to