webservice asp.net

A

Arno

How do I call a webservice from a webapplication in
ASP.NET??

I do not have any experience

Can you recommenc me good books??

thank you
 
D

Dino Chiesa [MSFT]

check out a tutorial for a basic ASMX webservice.
It should show you how to build a client.

what you want to do, I suppose, is use an ASPX module as a client of the
ASMX.
In this case, the ASPX is the client, and must reference the webservice
proxy.

You need to compile the generated proxy classes into a DLL and drop them
into the bin dir of the ASP.NET app.

example:
http://www.aspalliance.com/cookbook/ViewChapter.aspx?Chapter=19


-Dino
 
A

Arno

How do I compile the proxy classes into a dll??

and where do I put mu business classes?
 
D

Dino Chiesa [MSFT]

Arno,
To compile you would use the langiuage compiler. For C#, that is csc.exe
located in
c:\windows\Microsoft.NET\Framework\v1.1.4322\csc

and you would invoke it thusly:
csc /target:library /out:MyLibrary.dll Module1.cs Module2.cs Module3.cs

On the cmd line include all of the C# modules you want to combine into the
DLL. This might be just one C# file: the proxy generated from wsdl.exe.
But you might have other helper classes, or you might decide you want to
inherit from the proxy, etc. Probably if you are just starting, you would
have just the one source module.

The resulting DLL goes into the bin dir, as I said.

For business classes, you have a couple of options.
1. You can build them into a DLL in the same way - the only difference here
is that rather than starting with"generated" code - generated from
wsdl.exe - you will be starting with code you have written. You compile and
drop the DLL into the bin, just like with the proxy. In fact there is no
technical difference whatsoever. Then you call the "business methods" from
your aspx server-side script.

2. you can also use code-behind, and utilize the ASP.NET infrastructure to
compile your "business methods" at runtime, on demand. To do this, you
would code your aspx page (Maybe it is called "MyPage.aspx") like this:
<%@ Page Language="C#" ContentType="application/pdf" Inherits="MyClass"
src="MyClass.aspx.cs" %>

Then, you write a second source module, called "MyClass.aspx.cs" and drop
that into the same web directory with your MyPage.aspx. This module ought
to look like so:

public class MyClass : System.Web.UI.Page {
private void Page_Load(object sender, System.EventArgs e) {
....
}
...

}

In that class you can provide methods for any of the page-level events, such
as the skeletal Page_Load() shown above. For more on the page-level
events see
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebUIPageClassTopic.asp

or google for "code behind"
http://www.google.com/search?hl=en&num=30&q="code+behind"

-------

Of course, you can use a combination of code-behind (#2) and DLLs (#1) in
your ASP.NET apps.

------------
This post is probably not enough to get you really rolling. Look at some
working samples, especially the ASP.NET quickstarts that are included in the
..NET SDK.
C:\netsdk\QuickStart\aspplus\samples\webforms\intro is a nice place to
start.

Even better, Get yourself a book!

"ASP.NET Unleashed" is a fine one, but there are a million other ASP.NET
books out there.

-Dino
 

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,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top