Wrox Programmer Forums
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 31st, 2003, 06:34 AM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yangzhongbin
Default Post xml using c#

I try to write API to post a xml stream to a servlet ,
who can help me to give me some example using C#
thanks

yang
 
Old November 1st, 2003, 11:44 PM
Authorized User
 
Join Date: Jun 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sempf
Default


When you say servelet, do you mean like an HTTP stream? Servelet to me says Enterprise Java Beans, and doesn't really apply in the Microsoft world. Sending an XML stream to an HttpStreamWriter shouldn't be hard. Tell me exactly what you are trying to accomplish.

Bill Sempf
Effective Visual Studio .NET
 
Old November 3rd, 2003, 06:23 AM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yangzhongbin
Default

what i am trying to do is using a client-side application(C#) collect customer information and generate a xml stream (using XMLTextWriter), after that post the stream using webhttprequest send to a domino server. in server side I write a servlet to received the stream and using parser(ibm xmlparser) to transform the information to a Domino document and store it.
I have successed post the xml stream to servlet and create a domino document.
but now there is a problem when I try to insert a data to a RTF field
(Rich text Field).

I want to konw why when i create a xml file using XMLTextWriter in C# the file always start with some symbol like "?" "-" . although we can not see this kind of symbol from IE(because we can using IE open the xml file, and there is no error).
if using java open the file
for example I using followwing method
URL url=new URL("http://localhost/Temp.xml");
InputStream input=url.openStream();
String line;
while((line=input.readLine())!=null)
{
System.out.println(line);

}

the output will like this
?<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE BOOK[
                           <!ELEMENT BOOK (ALL)>
                           <!ELEMENT TITLE (#PCDATA)>
                           <!ELEMENT PUBLICATION_DATE (#PCDATA)>
                           <!ELEMENT ISBN_NO (#PCDATA)>
                           <!ELEMENT AUTHOR (NAME,GENDER)>
                           <!ELEMENT NAME (#PCDATA)>
                           <!ELEMENT GENDER (#PCDATA)>
                           <!ELEMENT PRICE (#PCDATA)>

                           ]>
<BOOK>
  <TITLE>sf</TITLE>
  <PUBLICATION_DATE>kjjk</PUBLICATION_DATE>
  <ISBN_NO>jjk</ISBN_NO>
  <AUTHOR>
    <NAME>gdfk</NAME>
    <GENDER>dkfj</GENDER>
  </AUTHOR>
  <PRICE>jj</PRICE>
</BOOK>



following is what i have finished in coding
please help me is here more efficient way to do post or received method
in C#(client)

....
string uri=txtUri.Text;
WebRequest req=WebRequest.Create(uri);
req.Timeout=120000
req.Method="POST";
req.ContentType="text/xml";
Stream stream=req.GetRequestStream();
xtw.Formatting=Formatting.Indented;
xtw.WriteStartDocument();
xtw.WriteDocType("BOOK",null,null,subset);
xtw.WriteStartElement("BOOK");
xtw.WriteElementString("TITLE",bookTitle);
xtw.WriteElementString("PUBLICATION_DATE",publicat ionDate);
xtw.WriteElementString("ISBN_NO",isbnNo);
xtw.WriteElementString("GENRE",genre);
xtw.WriteStartElement("AUTHOR");
xtw.WriteElementString("NAME",authorName);
xtw.WriteElementString("GENDER",gender);
xtw.WriteEndElement();
xtw.WriteElementString("PRICE",price);
xtw.WriteEndElement();
xtw.WriteEndDocument();
xtw.Flush();
xtw.Close();
...

in servlet (server)

.....

java.io.InputStream input=request.getInputStream();
      FileOutputStream fos=new FileOutputStream("C:\\Temp.xml");

      int c;

      while ((c = input.read()) != -1) {
        fos.write(c);
      }

      input.close();
      fos.close();

com.ibm.xml.parser.Parser ibmParser=new com.ibm.xml.parser.Parser("C:\\Temp.xml");
      InputStream input2 =new FileInputStream("C:\\Temp.xml");

      org.w3c.dom.Document orgDoc=ibmParser.readStream(input2);
      Element element=orgDoc.getDocumentElement();
      input2.close();
......


anyway please forgive me my poor english!
thank you very much for your help

yang
 
Old November 3rd, 2003, 10:06 PM
Authorized User
 
Join Date: Jun 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sempf
Default


The '? ' is from the UTF-8 encoding used by Microsoft when saving the XML to memory while you are building it. Check out this article for a solution:

http://support.microsoft.com/?id=317661

HTH



Bill Sempf
Effective Visual Studio .NET
 
Old November 4th, 2003, 10:16 PM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yangzhongbin
Default

thanks for your help!



yang
 
Old November 7th, 2003, 01:49 AM
Authorized User
 
Join Date: Jun 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sempf
Default


Did that solve the problem?



Bill Sempf
Effective Visual Studio .NET
 
Old November 7th, 2003, 05:44 AM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yangzhongbin
Default

 hi:
   not really solve the problem, but I have change my idea to give up read the text from the xml stream, i just simply add the xml file as a attachement to a RTF field in domino document.

yang





Similar Threads
Thread Thread Starter Forum Replies Last Post
Post a xml file to an URL? chengjianjin XML 10 June 10th, 2010 02:05 AM
XML HTTP Post acdsky Servlets 2 June 2nd, 2005 10:59 AM
GET URL FROM XML POST kevorkian Classic ASP XML 4 December 23rd, 2004 11:31 AM
XML Post using microsoft.XMLHTTP csmajor231 XML 0 April 5th, 2004 03:06 PM
Post XML vrbhatt VS.NET 2002/2003 7 December 5th, 2003 05:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.