http post

7 views
Skip to first unread message

Nivas

unread,
May 22, 2009, 2:38:54 AM5/22/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi,

i need to send a xml file to another webserver, which i want to do in
csharp. how to do this?
Maybe have to do something with SSLSocket.

Thanks in advance.

Chris Marks

unread,
May 22, 2009, 7:24:35 AM5/22/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
"Send" ? - perhaps use of a webservice, or if it's just literally to
send/upload a file an XML file to a remote webserver, how about
connecting via FTP?

(¯`·._.·NIVAS·._.·´¯)

unread,
May 25, 2009, 10:12:35 AM5/25/09
to DotNetDe...@googlegroups.com
Hi Chris,
Its not meagre upload file. I have to send xml content as data using http post and inturn another webserver will give response for my request.

--
Tha.Nivas,
http://cdnivas.blogspot.com

cipto john

unread,
May 25, 2009, 10:44:55 PM5/25/09
to DotNetDe...@googlegroups.com
if from javascript
Use post on xmlhttprequest. set to post and then set your xml as string.handle it on server write the string to xml file

if from other type application
Using FTP would be nice.

of you build your tcp listener accept client bla bla bla

There is nothing to do with ssl, ssl is just encryption.

(¯`·._.·NIVAS·._.·´¯)

unread,
May 27, 2009, 2:04:15 AM5/27/09
to DotNetDe...@googlegroups.com
Hi Cipto,
 
Thanks for your reply. I have implemented that usin HttpWebRequest and is done.
Thanks all.
--
Tha.Nivas,
http://cdnivas.blogspot.com

Rico

unread,
May 28, 2009, 2:12:23 AM5/28/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hello Nivas,

I'm trying to do a similar thing. Could you please post your code for
the POST and for the web service?

Thanks,
Rico

On May 26, 11:04 pm, (¯`·._.·NIVAS·._.·´¯) <cdni...@gmail.com> wrote:
> Hi Cipto,
>
> Thanks for your reply. I have implemented that usin HttpWebRequest and is
> done.
> Thanks all.
>
>
>
>
>
> On Tue, May 26, 2009 at 8:14 AM, cipto john <ciptoj...@gmail.com> wrote:
> > if from javascript
> > Use post on xmlhttprequest. set to post and then set your xml as
> > string.handle it on server write the string to xml file
>
> > if from other type application
> > Using FTP would be nice.
>
> > of you build your tcp listener accept client bla bla bla
>
> > There is nothing to do with ssl, ssl is just encryption.
>
> > On Mon, May 25, 2009 at 9:12 PM, ¯`·._.·NIVAS·._.·´¯ <cdni...@gmail.com>wrote:
>
> >> Hi Chris,
> >> Its not meagre upload file. I have to send xml content as data using http
> >> post and inturn another webserver will give response for my request.
>
> >> On Fri, May 22, 2009 at 4:54 PM, Chris Marks <chris.ma...@gmail.com>wrote:
>
> >>> "Send" ? - perhaps use of a webservice, or if it's just literally to
> >>> send/upload a file an XML file to a remote webserver, how about
> >>> connecting via FTP?
>
> >>> On May 22, 7:38 am, Nivas <cdni...@gmail.com> wrote:
> >>> > Hi,
>
> >>> > i need to send a xml file to another webserver, which i want to do in
> >>> > csharp. how to do this?
> >>> > Maybe have to do something with SSLSocket.
>
> >>> > Thanks in advance.
>
> >> --
> >> Tha.Nivas,
> >>http://cdnivas.blogspot.com
>
> --
> Tha.Nivas,http://cdnivas.blogspot.com- Hide quoted text -
>
> - Show quoted text -

Rico

unread,
May 27, 2009, 8:47:02 PM5/27/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi Nivas,

Can you post the code of how you used a HttpWebRequest to POST an XML
file to a web service and the web service code as well?

I'm trying to do something similar.

Thanks,
Rico

On May 26, 11:04 pm, (¯`·._.·NIVAS·._.·´¯) <cdni...@gmail.com> wrote:
> Hi Cipto,
>
> Thanks for your reply. I have implemented that usin HttpWebRequest and is
> done.
> Thanks all.
>
>
>
>
>
> On Tue, May 26, 2009 at 8:14 AM, cipto john <ciptoj...@gmail.com> wrote:
> > if from javascript
> > Use post on xmlhttprequest. set to post and then set your xml as
> > string.handle it on server write the string to xml file
>
> > if from other type application
> > Using FTP would be nice.
>
> > of you build your tcp listener accept client bla bla bla
>
> > There is nothing to do with ssl, ssl is just encryption.
>
> > On Mon, May 25, 2009 at 9:12 PM, ¯`·._.·NIVAS·._.·´¯ <cdni...@gmail.com>wrote:
>
> >> Hi Chris,
> >> Its not meagre upload file. I have to send xml content as data using http
> >> post and inturn another webserver will give response for my request.
>
> >> On Fri, May 22, 2009 at 4:54 PM, Chris Marks <chris.ma...@gmail.com>wrote:
>
> >>> "Send" ? - perhaps use of a webservice, or if it's just literally to
> >>> send/upload a file an XML file to a remote webserver, how about
> >>> connecting via FTP?
>
> >>> On May 22, 7:38 am, Nivas <cdni...@gmail.com> wrote:
> >>> > Hi,
>
> >>> > i need to send a xml file to another webserver, which i want to do in
> >>> > csharp. how to do this?
> >>> > Maybe have to do something with SSLSocket.
>
> >>> > Thanks in advance.
>
> >> --
> >> Tha.Nivas,
> >>http://cdnivas.blogspot.com
>
> --

tha. NIVAS

unread,
May 28, 2009, 6:50:38 AM5/28/09
to DotNetDe...@googlegroups.com
Hi Rico,
 
This is how i implemented the Http post.
 
 
String
result = string.Empty;

StreamWriter myWriter = null;

string url = ConfigurationManager.AppSettings["Host"];

//Creating a WebRequest

HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);

httpWebRequest.Method =

"POST";

httpWebRequest.ContentLength = xmlMessage.Length;

httpWebRequest.ContentType =

"text/xml;charset=ISO-8859-1";

httpWebRequest.Headers.Add(

HttpRequestHeader.Authorization, ConfigurationManager.AppSettings["Authorization"]);

try

{

myWriter =

new StreamWriter(httpWebRequest.GetRequestStream());

//Writes to the host sever

myWriter.Write(xmlMessage);

}

catch (Exception e)

{

throw e;

}

finally

{

if (myWriter != null)

{

myWriter.Close();

}

}

//Getting response from host server for our request

HttpWebResponse objResponse = (HttpWebResponse)httpWebRequest.GetResponse();

using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))

{

result = sr.ReadToEnd();

// Close and clean up the StreamReader

sr.Close();

}

Regards,
Nivas

--
Regards,
tha.NIVAS

Rico

unread,
May 28, 2009, 12:27:03 PM5/28/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Thank you Nivas. However I'm still having an issue where I'm getting
an HTTP 500 error. I found some information about adding a line in
web.config to allow HTTP Post as opposed to SOAP, but that didn't seem
to lead anywhere. Did you have to do anything like that? Also what
does your web method look like. Is it something like this?

[WebMethod]
public string PostXML(Stream fileByteStream)
{
if (Process(fileByteStream))
{
return "OK";
}
else
{
return "Fail";
}

Thanks again, Rico
> > > Tha.Nivas,http://cdnivas.blogspot.com-Hide quoted text -
>
> > > - Show quoted text -
>
> --
> Regards,
> tha.NIVAS- Hide quoted text -

tha. NIVAS

unread,
May 29, 2009, 6:42:37 AM5/29/09
to DotNetDe...@googlegroups.com
Hi Rico,
 
I have no idea of how the webmethod looks because its 3rd party application. Moreover i m posting to .jsp and not to .asmx file.
 
Regards,
Nivas D
--
Regards,
tha.NIVAS
Reply all
Reply to author
Forward
0 new messages