Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services 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 September 10th, 2004, 03:15 PM
Registered User
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Simple HTTP POST .Net web service?

  A customer of ours wants us to provide a web service that they can access WITHOUT SOAP. They just want to do an HTTP POST to some URL I provide. They will put the XML in the data of the post. We want to do this in .NET in C#.

  OK, so I figured out how to do it, but it seems very backward. I keep thinking there is a better way. Here is what we did:

1) We have a .NET web service that takes NO parameters.
2) It gets the XML with the following lines:
   String postData = this.Context.Request.Form.ToString();
   sxml = System.Web.HttpUtility.UrlDecode(postData);

3) Then, it uses standard XML tools to extract the data from his XML:
    XmlNodeList nodeLst = doc.GetElementsByTagName("OrderInfo");
    ... etc.
4) Finally, it builds an XML result string (a character string) and returns it with
    return sResult;

Is this the best way to hanlde this? It seems that I'm bypassing all of the cool .NET web service tools by getting it from the Request.Form.Tostring. But I don't see a better way.

Also (an annoyance I'll probably figure out sooner or later) when it comes back to him he is seen > instead of GREATER THAN and < instead of LESS THAN in the XML result string. Which setting is causing that to happen?

Thanks much!
Old September 10th, 2004, 04:46 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

I can't think of a much better way. Yes, you are passing up all the nifty .NET functionality of web services. I can't imagine why they would be so adament about not using SOAP. The only other option would be to use the querystring, but that would be somewhat limiting.

When you return a "<" in xml as part of the data, it get escaped because if it didn't it would break the validation of a properly formed XML string/document:

   <data>If x = 5 and y = 10 then 5 < 10 </data>

The "<" implies the beginning of a tag where there really isn't one. So it get escaped:

   <data>If x = 5 and y = 10 then 5 &lt; 10 </data>

The consumer would have to unescape the string. (Something that wouldn't be necessary if they used SOAP, I think. Certainly not if they did it in .NET.)

Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.net http post with file Master .NET Framework 1.x 0 November 20th, 2008 09:21 AM
Web Service to accept HTTP-Get jasonfisher .NET Web Services 1 June 9th, 2005 09:31 AM
Consuming web services in asp.net using http post dpk100 .NET Web Services 1 May 4th, 2005 02:03 AM
Call the Java Web Service using HTTP-POST/GET anand_indya J2EE 0 January 17th, 2005 08:23 AM
HTTP Post .Net sjlsysprg1 Pro VB.NET 2002/2003 5 June 26th, 2003 12:20 PM

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