Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Beginner with Questions re: WPF, WCF, LINQ

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave - 17 Mar 2008 00:11 GMT
Hi All,

I am coming from a PHP, Java background. I am just getting started with C#
and I am trying to figure out how to program something (I have about 3 months
to do it). All I want is a confirmation of the direction I am going and then
I will start to learn everything.

We have a DB2 database. I am assuming I can write a WCF service to access
this database and return the data from the service to a WPF front end app
(the service and front end will be on different machines). Will the data from
the service be returned in only XML format or can the service send the data
back in another format? If it sends back only in XML then can I use LINQ to
XML to display the data in a WPF front end? I guess I just need some kind of
confirmation that I am on the right track on how all these things work
together.

Thanks
Arne Vajhøj - 17 Mar 2008 00:19 GMT
> We have a DB2 database. I am assuming I can write a WCF service to access
> this database and return the data from the service to a WPF front end app
> (the service and front end will be on different machines).

Yes. Note though that a SOA web service is supposed to expose
business services not raw table data.

>                                                             Will the data from
> the service be returned in only XML format or can the service send the data
> back in another format?

WCF support multiple formats including SOAP and Remoting (equivalent
to Java RMI).

>                        If it sends back only in XML then can I use LINQ to
> XML to display the data in a WPF front end?

In theory yes, but that would be a cumbersome way to do it.

Let .NET unpack it so you have the same data structure as the server
send.

Arne
Dave - 17 Mar 2008 00:31 GMT
Thanks for the reply.

I was thinking the webserver would do something like:

User sends "Account Number" to service
Service replies with "Account Information, Balance, etc etc".
Then the front end would display the returned information somehow.

When you say "Let .NET unpack it" to get the same "data structure", are you
saying the Service can return data in a dat structure instead of just XML
data? If so, what is the technical term for this so I can start investigating
this way?

Thanks again

> > We have a DB2 database. I am assuming I can write a WCF service to access
> > this database and return the data from the service to a WPF front end app
[quoted text clipped - 19 lines]
>
> Arne
Arne Vajhøj - 17 Mar 2008 00:40 GMT
> I was thinking the webserver would do something like:
>
[quoted text clipped - 6 lines]
> data? If so, what is the technical term for this so I can start investigating
> this way?

yes

web reference
web service stub

Let me give an example.

Oldfashioned .asmx not WCF, but anyway.

Server side:

    public class Test : WebService
    {
        [WebMethod]
        public Foobar TestIt()
        {
            Foobar res = new Foobar();
            res.Iv = 123;
            res.Sv = "ABC";
            return res;
        }
    }

Client side:

        Test serv = new Test();
        Foobar tst = serv.TestIt();

The Test and Foobar class used client side are generated
from the WSDL of the web service.

Remoting works similar.

And WCF as well (from what I have read - I have not used WCF yet).

Arne
Dave - 17 Mar 2008 00:51 GMT
OK I think I understand. I guess my confusion was that I thought the service
only returned XML data. Returning data this way is much better.

Thanks

> > I was thinking the webserver would do something like:
> >
[quoted text clipped - 43 lines]
>
> Arne
Arne Vajhøj - 17 Mar 2008 00:58 GMT
> OK I think I understand. I guess my confusion was that I thought the service
> only returned XML data. Returning data this way is much better.

It does. But you don't see it.

You write server side code that return an object. The container
serialize that object as SOAP XML.

You write client side code that calls a generated stub. That
stub deserialize the received SOAP XML as an object.

The benefits of the SOAP XML is that the client side
and server side does not need to be in the same technology. You
can call a Java web service from C# or a VB.NET web service in PHP.

But you do not need to worry about the details of SOAP XML. You can
focus on the real problem.

Arne
Dave - 17 Mar 2008 01:07 GMT
OK I am starting to understand. Basically the service does return XML but the
frontend will create a data object from the XML automagically.

Now I need to find a good tutorial on all this stuff.

Thanks again for clearing this up for me.

> > OK I think I understand. I guess my confusion was that I thought the service
> > only returned XML data. Returning data this way is much better.
[quoted text clipped - 15 lines]
>
> Arne
Arne Vajhøj - 17 Mar 2008 01:42 GMT
> OK I am starting to understand. Basically the service does return XML but the
> frontend will create a data object from the XML automagically.
>
> Now I need to find a good tutorial on all this stuff.

Some random googling:

.asmx

http://my.execpc.com/~gopalan/dotnet/webservices/webservice_server.html
http://www.15seconds.com/issue/010430.htm

WCF

http://www.dotnetfun.com/articles/framework/3.0/WCFBasicServiceContract.aspx

remoting

http://www.csharphelp.com/archives2/archive314.html
http://www.beansoftware.com/NET-Tutorials/NET-Remoting-Tutorial.aspx

Arne
Steve Gerrard - 17 Mar 2008 01:47 GMT
> OK I am starting to understand. Basically the service does return XML
> but the frontend will create a data object from the XML automagically.
>
> Now I need to find a good tutorial on all this stuff.
>
> Thanks again for clearing this up for me.

Just to reiterate, a web service can return a DataSet. It will actually be XML
data, following Microsoft's diffgram XML schema, but for all intents and
purposes, it is a dataset.

The client can call the method that returns a dataset, perhaps passing some
parameter values, and assign the return value to a dataset variable. As you put
it, all the xml processing happens automagically.

It can be a bit bulky for returning many rows, since the column names will be
repeated twice for each row in the actual XML, but it works very smoothly.
Arne Vajhøj - 17 Mar 2008 02:55 GMT
>> OK I am starting to understand. Basically the service does return XML
>> but the frontend will create a data object from the XML automagically.
[quoted text clipped - 13 lines]
> It can be a bit bulky for returning many rows, since the column names will be
> repeated twice for each row in the actual XML, but it works very smoothly.

I would not use a DataSet for a web service. It will not be consumable
from non-.NET clients.

Arne
Steve Gerrard - 17 Mar 2008 04:20 GMT
> I would not use a DataSet for a web service. It will not be consumable
> from non-.NET clients.

In the practical sense, it is quite unlikely. It is a published schema, so
technically it is possible for a non .Net program to receive the xml data and
the schema, and to create its own version of a dataset.

If you are developing both the web service and the client in .Net, however, and
that it is its principle purpose, it works out fine.
Dave - 17 Mar 2008 05:14 GMT
Thanks again for all the info....

For the immediate future, the client will be .NET but down the road (maybe
in a year or so) they will want me to do some Blackberry programming using
the same services. I was hoping I wouldn't need to rewrite anything....

> > I would not use a DataSet for a web service. It will not be consumable
> > from non-.NET clients.
[quoted text clipped - 5 lines]
> If you are developing both the web service and the client in .Net, however, and
> that it is its principle purpose, it works out fine.
Steve Gerrard - 17 Mar 2008 05:34 GMT
> Thanks again for all the info....
>
> For the immediate future, the client will be .NET but down the road
> (maybe in a year or so) they will want me to do some Blackberry
> programming using the same services. I was hoping I wouldn't need to
> rewrite anything....

I have no idea what you would need for Blackberry.

One thing to consider is that if the web service is going to get the data from
the database as a dataset, you can then expose it two (or more) ways: one method
returns it as a dataset; another method returns it as an array of data elements,
or whatever.

I did a little thing like that to allow an older , non .Net, program to exchange
data with the service as arrays of strings. Not ready for public consumption,
but effective for the task at hand.

So you could build around a dataset now, and work out a second way to expose the
data later. Or you start creating all your own data classes that you would need
to make a more general purpose web service.
Dave - 17 Mar 2008 06:12 GMT
Thanks Steve,

I assume a dataset would be easier to work with than an array? I guess I
should go that route for now until I get up to speed on C#. I have alot to do
in a very short amount of time and I have never done any .NET programming so
right now Im looking for quickest and easiest.

> > Thanks again for all the info....
> >
[quoted text clipped - 17 lines]
> data later. Or you start creating all your own data classes that you would need
> to make a more general purpose web service.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.