General Question About Web Service Architecture

P

pbd22

Hi.

I am generally wondering about the best type of architecture when
designing a web service. It would be helpful to me if somebody could
look at the below "flow" and comment accordingly (does this look
right?). Also, I have two related questions:

1) Will web service calls always be initiated from within the context
of a JavaScript function (as described in #3)?

2) Will the actual web service (the code that grabs data and returns
it as an xml or json - formatted string) always be a separate and
distinct web project from my main Web application?

THIS HAPPENS IN MY MAIN WEB PROJECT:

1) ASPX page button click event

2) fire click_button() on same page

3) from the click_button() function
a call to the location of the web service
server is made passing the click events
associated values. For example:

..getJSON("http://api.domain.com/services/dosomething?q=words")

THIS HAPPENS IN MY WEB SERVICE PROJECT:

4) In the code behind of the dosomething.aspx page, a
SOAP call (SomethingService someserv = new SomethingService();) is
made to a service that that retrieves
data and formats it (say, JSON) for response to the client.

Thanks in advance. I appreciate your time and expertise.
 
M

Mr. Arnold

pbd22 said:
Hi.

I am generally wondering about the best type of architecture when
designing a web service. It would be helpful to me if somebody could
look at the below "flow" and comment accordingly (does this look
right?). Also, I have two related questions:

1) Will web service calls always be initiated from within the context
of a JavaScript function (as described in #3)?

I don't know what you're talking about. You don't need JavaScript to make a
Web service call. You can call the Web service from a Windows desktop
solution, as an example. A Web service can be called from MVP, MVC, BLL or
DAL layers, that have nothing to do with JavaScript.
2) Will the actual web service (the code that grabs data and returns
it as an xml or json - formatted string) always be a separate and
distinct web project from my main Web application?

It should be a separate project that can be part of a total solution in the
..snl. But nevertheless, it should be a separate project. The Web service is
a Web site offering a service that should be/can be consumed by any type of
client, not just an ASP.NET solution.
THIS HAPPENS IN MY MAIN WEB PROJECT:

1) ASPX page button click event

2) fire click_button() on same page

3) from the click_button() function
a call to the location of the web service
server is made passing the click events
associated values. For example:

.getJSON("http://api.domain.com/services/dosomething?q=words")

THIS HAPPENS IN MY WEB SERVICE PROJECT:

4) In the code behind of the dosomething.aspx page, a
SOAP call (SomethingService someserv = new SomethingService();) is
made to a service that that retrieves
data and formats it (say, JSON) for response to the client.

It should just be XML as you should make the solution more viable to other
types of clients that may want to consume the Web service.


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4279 (20090726) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
P

pbd22

Thanks Mr. Arnold.

I appreciate the response.

I think I need to back up a bit and explain where I am getting
stuck...

I have a WCF Class Library that contains a number of
interfaces:

ITradeService
IAuthService
IHelperService
And so on...

I was reading through a blog that described how to use
AJAX/JSON/WCF to populate client-side data. The
javascript call looked something like (I think this is jquery):

Code:

$(document).ready(function(){
$.getJSON("http://api.domain.com/services/buy.svc?
q=" + query.value + "&type=" + type.value + "&format=json",
function(data){
$.each(data.items, function(i,item){
$("<img/>").attr("src",
item.media.m).appendTo("#images");
if ( i == 3 ) return false;
});
});
});



Up until this point, I have been able to reference my WCF class
library (as a Service Reference) in my Web Project and call the
necessary methods.

But, the above code got me asking the question - "What is a SVC file
and why do I need it"? Apparently if I want to expose my interfaces to
the rest of the world, I need an SVC file?

MY QUESTION IS - What is the best way to go about exposing the
endpoints described in my current WCF client library?

Based on some online gardening, I have found the following:

1) Create a WCF application under the solution and reference the WCF
class library in this project. Then, create a client proxy that
exposes the library's end points. Finally, reference the the newly
created WCF service as a Web Service in the Web Application.

2) Reference the WCF Client Library in my Web Application, exposing
the endpoints by using something called a "ClientFactory"? Does that
sound correct?

I would prefer to avoid a proxy if I can and option number two sounds
like a good bet. I don't really understand, however, how this works.

Could you (or somebody) explain how to expose the endpoints in my WCF
class library without creating a proxy? Also, what would the AJAX
JavaScript call look like?

I hope I have done a better job at explaining myself. Thanks again for
your time and help.
 
M

Mr. Arnold

pbd22 said:
Thanks Mr. Arnold.

I appreciate the response.

I think I need to back up a bit and explain where I am getting
stuck...

I have a WCF Class Library that contains a number of
interfaces:

ITradeService
IAuthService
IHelperService
And so on...

I was reading through a blog that described how to use
AJAX/JSON/WCF to populate client-side data. The
javascript call looked something like (I think this is jquery):

Code:

$(document).ready(function(){
$.getJSON("http://api.domain.com/services/buy.svc?
q=" + query.value + "&type=" + type.value + "&format=json",
function(data){
$.each(data.items, function(i,item){
$("<img/>").attr("src",
item.media.m).appendTo("#images");
if ( i == 3 ) return false;
});
});
});



Up until this point, I have been able to reference my WCF class
library (as a Service Reference) in my Web Project and call the
necessary methods.

But, the above code got me asking the question - "What is a SVC file
and why do I need it"? Apparently if I want to expose my interfaces to
the rest of the world, I need an SVC file?

The svc file exposes the Web service to a Internet or Intranet client.
MY QUESTION IS - What is the best way to go about exposing the
endpoints described in my current WCF client library?

Based on some online gardening, I have found the following:

1) Create a WCF application under the solution and reference the WCF
class library in this project. Then, create a client proxy that
exposes the library's end points. Finally, reference the the newly
created WCF service as a Web Service in the Web Application.

2) Reference the WCF Client Library in my Web Application, exposing
the endpoints by using something called a "ClientFactory"? Does that
sound correct?

I would prefer to avoid a proxy if I can and option number two sounds
like a good bet. I don't really understand, however, how this works.

Could you (or somebody) explain how to expose the endpoints in my WCF
class library without creating a proxy? Also, what would the AJAX
JavaScript call look like?


How hard can it be to look this up using Bing or Google.

I hope I have done a better job at explaining myself. Thanks again for
your time and help.

What you need to do is create a WCF Web service reference in a project, by
using the .svc file and pasting it in the Service Reference wizard of a
project. The outputted App.config file will contain the WCF Web service
entries that you would copy to the Web.config of the ASP.NET client project,
under <system.serviceModel>. If the WCF Web service is created with the
Service Reference wizard in an ASP.NET client project, then it's going to
put the WCF config info into in the Web.Config itself.

I suggest you get yourself a good WCF book and start at page 1 and the
basics, before you get to the complicated stuff. The book will go over the
complicated stuff too. Most of these books you don't even have to buy
anymore because of free e-books and Google books online.






__________ Information from ESET NOD32 Antivirus, version of virus signature database 4289 (20090729) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top