0

This is my homework, the hard one!
I need to build an online quiz, using ASP.NET MVC, include a desktop version (WPF) that can share the data with the web version using a XML Web Service - WCF. My teacher does not specific what kind of XML Web Service, after some research I choose SOAP because SOAP is a W3C recommendation and here is my plan:

A. When user write a quiz, in the Web site oe Desktop app, the submitsion will send data to WCF service. A list of different type of Item send to the server and save it to database.

B. When user do a quiz, all the data will submit to WCF service, and the total point is return by WCF service too.

After do some research on MSDN, I see that WCF can handle SOAP, but I can't find any document that show me how to do that. Either I'm very new to SOAP to process A and B action.

I have found some documents about using WCF with Entity framework and Code First: http://msdn.microsoft.com/en-us/data/gg601462 http://blogs.msdn.com/b/adonet/archive/2011/03/21/using-wcf-data-services-with-entity-framework-4-1-and-code-first.aspx

These documents help me to build a Web service and retrieve data from my database, I think that is not in SOAP style.
SO now, I think what I need is:

  • Some recommends about what kind of XML Web Service.
  • Some documents show me how to handle SOAP with WCF if you say SOAP is ok for may app.

Thanks you alot for sharing!

1 Answer 1

1

I'm not going to do your homework for you fully... but I'll get you started on how to consume a WCF service the easy way.

First, WCF can use SOAP, JSON, or many other transport methods. By default if you are using a asp.net application and it calls a WCF service it uses SOAP. The XML that WCF uses is much more complex than a simple SOAP call you might hand build.

Second, to consume a WCF service from a asp.net app you can have Visual Studio create you "proxy" code that handles all the nitty gritty xml stuff for you.

To accomplish that, in Visual Studio in the Solution Explorer right click on the project name and click "Add Service Reference". Type in the URL of your service (http://localhost:9821/service.svc). It will auto discover the WCF service information there. Note the "Namespace". That Namespace is where the proxy code is kept.

If your service namespace was "MyService", then in your application code you would "imports/using" that namespace. AKA: Imports MyService

Then your code would use it:

Dim serviceclient as new MyService.ServiceClient
serviceClient.myWCFFunction();
Sign up to request clarification or add additional context in comments.

7 Comments

Thanks for your help! I already know how to add WCF service to MVC application (like I said in my question). But are you sure that WCF default call a SOAP? Why I read that SOAP just enable to receive POST data?
Are you using WCF Data Services? Or are you using straight up WCF?
I not sure about that...I just follow this video: msdn.microsoft.com/en-us/data/gg601462 , the title is "Building an OData Service" so I think that is WCF Data Service, in this video he can type what he want in the address bar and enter...wow...all he need show up!
That makes sense now. OData (WCF Data Services) doesn't use SOAP, it use an XML format called Atom. msdn.microsoft.com/en-us/library/cc907912.aspx - Go to the second section where it talks about examples. So what your asking for is how can you use WCF to return your data, but use SOAP?
WCF defaults to SOAP over a secure channel.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.