C#.NET Web Service Help

Associate
Joined
28 Nov 2004
Posts
1,237
Location
Birmingham
Hi there,
I'm creating a webservice to return a number of items from a database. At the moment, I'm returning a DataSet of my results in the file. This is working ok but I have noticed my results are grouped as "NewDataSet". Is there a way I can customise the format of the XML returned.
e.g.
Code:
<NewDataSet xmlns="">  <Item diffgr:id="item1" msdata:rowOrder="0">   <unique_id>171</unique_id>   <reference>ITM-171</reference>     <title>test 3</title>    </Item>  <Item diffgr:id="item2" msdata:rowOrder="1">  <unique_id>160</unique_id>    <reference>ITM-171</reference>   <title>test 1</title>   
</Item>
 
DataSets are unruly, rigid and awkward remnants from the dark ages (basicly, before Linq...) ...

Tried to create your own DTO class for the records and return an IEnumerable of them instead? E.g.:

Code:
[DataContract(Name = "MyCustomName", Namespace =  "http://my.namespace")]
public class MyRecord {
    
    [DataMember]
    public string MyMember { get; set; }
    ...
}
 
Last edited:
Ok, so it looks like I drop the Dataset :)
This is a first attempt at a service so I'm expecting to be making improvements over time as well. Thanks both, I'll read up!
 
I'd not bother with a web service - they have been superseded by WCF (Windows Communication Foundation). Unless you need specifically to do a web service (i.e you're stuck targeting v1.1 or 2 of the framework), take a look at WCF.
 
I have seen that and whilst I'd like to, the server this will be deployed to is limited to .NET 3.5 at the moment so it's a no go...isn't it?
 
Last edited:
I'd not bother with a web service - they have been superseded by WCF (Windows Communication Foundation). Unless you need specifically to do a web service (i.e you're stuck targeting v1.1 or 2 of the framework), take a look at WCF.
Web services aren't going away, they're a big part of WCF.
 
Web services aren't going away, they're a big part of WCF.

WCF can be made to look like a web service for legacy reasons (basic HTTP binding). If you are starting from new it makes sense to use WCF, because it gives you more options and bindings. WCF is the future, web services aren't.
 
*cough* WCF is a web-service.

It's a service, on the web.

It's a soap service to be precise, nicely wrapped up in a library and, typically, given a new name to make you think Microsoft invented it.
 
*cough* WCF is a web-service.

It's a service, on the web.

It's a soap service to be precise, nicely wrapped up in a library and, typically, given a new name to make you think Microsoft invented it.

I think you're being a bit pedantic there. Whilst a service exposed over HTTP can be considered a 'web service', I wouldn't say a WCF service using basic HTTP binding is a classic web service, it just appears like one because of the binding used. WCF is far more flexible than a classic web service, its a unified framework for messaging.
 
WCF can be made to look like a web service for legacy reasons (basic HTTP binding).
Almost every out of the box WCF binding uses web service technology to some degree, even the tcp and named pipes bindings use SOAP 1.2. Web services are still the default choice when getting different technologies to talk to each other, or if you envisage some other system beyond your control will want to talk to you in the future, i.e. any moderately complex system. The only competitor is REST, and there still isn't a good way to describe a REST service declaratively.

WCF is the future, web services aren't.
That's a bold assertion. Boll0cks, but bold nonetheless. Web services will outlive WCF, because technology is easier to change than interaction contracts.
 
That's a bold assertion. Boll0cks, but bold nonetheless. Web services will outlive WCF, because technology is easier to change than interaction contracts.

I disagree, but there we go. I certainly wouldn't pick writing a .NET web service over writing a WCF service using a web binding. Its the same basic tech yes, but I'd argue the flexibility WCF gives you makes it a better choice. We have WCF services using basic HTTP binding integrating with all sorts of other technologies, because to them it's just a web service. But on that same service we use other bindings for internal integration.
 
I think you're being a bit pedantic there. Whilst a service exposed over HTTP can be considered a 'web service', I wouldn't say a WCF service using basic HTTP binding is a classic web service, it just appears like one because of the binding used. WCF is far more flexible than a classic web service, its a unified framework for messaging.

I'm not being pedantic, you're twisting the definition. How can you honestly state that anything that provides a service over the web, is not a web service? :confused:

I'm well aware of the so-called flexibilities with WCF. I'm also very aware of just how inflexible WCF actually is, despite what MS marketing tells you.
 
Last edited:
I'm not being pedantic, you're twisting the definition. How can you honestly state that anything that provides a service, over the web, is not a web service? :confused:

Ok ok. You are correct, a service providing data accessible via the web is a web service. My point is that WCF is much much more than a web service, at least in the sense of .NET.

I think I've trashed the OPs thread enough. My personal feeling is that he is better off writing a web service (service accessible over the web) using WCF, and not using a classic .asmx web service.
 
Quick overview of WCF vs other technologies...

wcf.jpg


People seem to be dwelling on the implementation (it's HTTP therefore it's a web service). WCF is the unification of all the other odds and sods MS has had lying around for ages with various different part-implementations; ASMX, MSMQ, Remoting, COM+ and WSE.

Oh, and back on topic, yes avoid datasets like the plague. They're ok for drag/drop coders obviously, as that's the type of user they are aimed at. But anyone doing anything serious will soon realise why they are a catastrophically bad idea.
 
The OP seems to be writing a classic .asmx web service. I simply suggested looking at WCF, which yes you can consume as a classic webservice using the basic HTTP binding (i.e. it looks like a web service to everything). However, it gives you so much more than just basic HTTP (which you are limited to with classic asmx services).

WCF not only gives you BasicHttpBinding, but also the following:
NetTcpBinding
NetNamedPipeBinding
NetMsmqBinding
WSHttpBinding
WSDualHttpBinding

The latter two are "web services", but unlike asmx web services you aren't limited to hosting in IIS (this is also true with the basic HTTP binding). Therefore, I wouldn't say that WCF is the same as a web service. Saying that WCF is just a web service is selling it very short, just like saying WCF is just .NET Remoting.

I highly recommend reading Juval Lowry's excellent Programming WCF Services.
 
I've read that book, and yes it is excellent for programming with WCF.

However, to still try and differentiate by saying WCF is not a web-service library is, well, an oxymoron. Anything that provides a service over the web is a web service. This website is a web-service. Google is a web-service.

I'd also be careful in thinking that the WCF service provides "much more" than "basic HTTP". It (HTTP) is greatly misunderstood. SOAP, for example - the foundation of WCF - is completely unnecessary when/if HTTP is used for its complete purpose. SOAP is also pure bloat in my opinion anyway. Microsoft have (finally) come to realise this, by developing a REST 'preview' for WCF, which is essentially a SOAP free version of WCF and uses HTTP for what it is meant to be used for - i.e. all the operations necessary (and/or even possible) for any web-service.

Also, just to point out to anyone unaware - the first three contract serialisers you have specified there, are very much .NET only - i.e. only a .NET client can consume them. :) The Net* prefix does mean .NET, not "Net"
 
I've read that book, and yes it is excellent for programming with WCF.

However, to still try and differentiate by saying WCF is not a web-service library is, well, an oxymoron. Anything that provides a service over the web is a web service. This website is a web-service. Google is a web-service.

I think you are confusing the term '.NET web service' with the words 'web service'. A .NET web service is defined pretty well by w3schools here - http://www.w3schools.com/ngws/ngws_webservices.asp

w3Schools said:
What are Web Services?

* Web services are small units of code
* Web services are designed to handle a limited set of tasks
* Web services use XML based communicating protocols
* Web services are independent of operating systems
* Web services are independent of programming languages
* Web services connect people, systems and devices

This web site and Google (apart from the Google API) fall outside of this definition.

.NET web services are considered to be one part of WCF, but WCF isn't just web services. Things like remoting, which never fell under the term 'web service', now shelter under the WCF unbrella as well.
 
Back
Top Bottom