473,396 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Writing a simple webservice


Hi guys, I'm looking to develop a simple web service in VB.NET but I'm
having some trivial issues. In Visual Studio I create a web services
project and change the asmx.vb file to this:

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel

<System.Web.Services.WebService(Namespace:="http ://
wwwpreview.#deleted#.co.uk/~ptaylor/Customer.wsdl")_
<System.Web.Services.WebServiceBinding(ConformsTo: =WsiProfiles.BasicProfile1_1)>
_
<ToolboxItem(False)_
Public Class CustomerService
Inherits System.Web.Services.WebService

<WebMethod()_
Public Function getCustomer() As TreeObject()

Dim t1 As New TreeObject
Dim t2 As New TreeObject
Dim t3 As New TreeObject

Dim arr(2) As TreeObject
arr(0) = t1
arr(1) = t2
arr(2) = t3

Return arr
End Function

End Class

As you can see my function returns an object of type "TreeObject" and
when you run this it works. the clients are clearly returned an array
3 TreeObjects objects. However I cannot actually invoke any functions
on these tree objects. This is the current definition of TreeObject:

Imports System.Web.Services

<System.Serializable()_
Public Class TreeObject

Public Sub New()

End Sub

<WebMethod()_
Public Sub setId(ByVal id As Int32)

End Sub

<WebMethod()_
Public Function getId() As String
Return 1
End Function

<WebMethod()_
Public Sub setName(ByVal value As String)
End Sub

<WebMethod()_
Public Function getName() As String
Return "boo ya"
End Function

End Class

However the functions GetName, SetName, GetId, SetId do not appear in
the WSDL file and the functions are not accessable from the client. (I
think TreeObject has no functions other than those inherited from
Object)

How do I make those functions accessible please? Do I need to set up
another "service" or what?

Thanks

Phill
Jun 27 '08 #1
10 2097
On 6 maio, 11:23, Phillip Taylor <Phillip.Ross.Tay...@gmail.com>
wrote:
Hi guys, I'm looking to develop a simple web service in VB.NET but I'm
having some trivial issues. In Visual Studio I create a web services
project and change the asmx.vb file to this:

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel

<System.Web.Services.WebService(Namespace:="http ://
wwwpreview.#deleted#.co.uk/~ptaylor/Customer.wsdl")_
<System.Web.Services.WebServiceBinding(ConformsTo: =WsiProfiles.BasicProfile1_1)>
_
<ToolboxItem(False)_
Public Class CustomerService
Inherits System.Web.Services.WebService

<WebMethod()_
Public Function getCustomer() As TreeObject()

Dim t1 As New TreeObject
Dim t2 As New TreeObject
Dim t3 As New TreeObject

Dim arr(2) As TreeObject
arr(0) = t1
arr(1) = t2
arr(2) = t3

Return arr
End Function

End Class

As you can see my function returns an object of type "TreeObject" and
when you run this it works. the clients are clearly returned an array
3 TreeObjects objects. However I cannot actually invoke any functions
on these tree objects. This is the current definition of TreeObject:

Imports System.Web.Services

<System.Serializable()_
Public Class TreeObject

Public Sub New()

End Sub

<WebMethod()_
Public Sub setId(ByVal id As Int32)

End Sub

<WebMethod()_
Public Function getId() As String
Return 1
End Function

<WebMethod()_
Public Sub setName(ByVal value As String)
End Sub

<WebMethod()_
Public Function getName() As String
Return "boo ya"
End Function

End Class

However the functions GetName, SetName, GetId, SetId do not appear in
the WSDL file and the functions are not accessable from the client. (I
think TreeObject has no functions other than those inherited from
Object)

How do I make those functions accessible please? Do I need to set up
another "service" or what?

Thanks

Phill
As I know, you need to public expose the methods in the .asmx.
Jun 27 '08 #2
On May 6, 4:02 pm, Thiago Macedo <thiago.ch...@gmail.comwrote:
On 6 maio, 11:23, Phillip Taylor <Phillip.Ross.Tay...@gmail.com>
wrote:
Hi guys, I'm looking to develop a simple web service in VB.NET but I'm
having some trivial issues. In Visual Studio I create a web services
project and change the asmx.vb file to this:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
<System.Web.Services.WebService(Namespace:="http ://
wwwpreview.#deleted#.co.uk/~ptaylor/Customer.wsdl")_
<System.Web.Services.WebServiceBinding(ConformsTo: =WsiProfiles.BasicProfile1_1)>
_
<ToolboxItem(False)_
Public Class CustomerService
Inherits System.Web.Services.WebService
<WebMethod()_
Public Function getCustomer() As TreeObject()
Dim t1 As New TreeObject
Dim t2 As New TreeObject
Dim t3 As New TreeObject
Dim arr(2) As TreeObject
arr(0) = t1
arr(1) = t2
arr(2) = t3
Return arr
End Function
End Class
As you can see my function returns an object of type "TreeObject" and
when you run this it works. the clients are clearly returned an array
3 TreeObjects objects. However I cannot actually invoke any functions
on these tree objects. This is the current definition of TreeObject:
Imports System.Web.Services
<System.Serializable()_
Public Class TreeObject
Public Sub New()
End Sub
<WebMethod()_
Public Sub setId(ByVal id As Int32)
End Sub
<WebMethod()_
Public Function getId() As String
Return 1
End Function
<WebMethod()_
Public Sub setName(ByVal value As String)
End Sub
<WebMethod()_
Public Function getName() As String
Return "boo ya"
End Function
End Class
However the functions GetName, SetName, GetId, SetId do not appear in
the WSDL file and the functions are not accessable from the client. (I
think TreeObject has no functions other than those inherited from
Object)
How do I make those functions accessible please? Do I need to set up
another "service" or what?
Thanks
Phill

As I know, you need to public expose the methods in the .asmx.
That's what I thought adding <WebMethod ()_ to everything did, but
it doesn't seem to be enough on it's own.
Jun 27 '08 #3
Phillip Taylor wrote:
>
<WebMethod()_
Public Function getCustomer() As TreeObject()

Dim t1 As New TreeObject
Dim t2 As New TreeObject
Dim t3 As New TreeObject

Dim arr(2) As TreeObject
arr(0) = t1
arr(1) = t2
arr(2) = t3

Return arr
End Function

End Class

As you can see my function returns an object of type "TreeObject" and
when you run this it works. the clients are clearly returned an array
3 TreeObjects objects. However I cannot actually invoke any functions
on these tree objects. This is the current definition of TreeObject:
When a WebService returns an Object to the calling program, it is sending the
data needed to create such an object. The data is being passed as XML. For the
calling program to use it, it must have the class definition of that object
available. It then creates a new instance of that class, and uses the data
received from the web service to initialize it. There is no sense in which you
are actually sending a functional object to the calling program.

Typically you would have a dll or similar that defines the class, with
properties identified as serializable, which is used by both the web service and
the calling program. When the web service is asked to return an instance of this
class, it returns as XML the values of the serializable properties. Then the
calling program creates an instance of the same class, and uses the serialized
XML data to make it the same as the one the web service used.

A good example is a Dataset, a class which both the web service and the calling
program can create. The web service can then be used to pass data serialized as
XML back and forth between a Dataset on the client and a Dataset on the server.

Jun 27 '08 #4
On May 6, 4:42 pm, "Steve Gerrard" <mynameh...@comcast.netwrote:
Phillip Taylor wrote:
<WebMethod()_
Public Function getCustomer() As TreeObject()
Dim t1 As New TreeObject
Dim t2 As New TreeObject
Dim t3 As New TreeObject
Dim arr(2) As TreeObject
arr(0) = t1
arr(1) = t2
arr(2) = t3
Return arr
End Function
End Class
As you can see my function returns an object of type "TreeObject" and
when you run this it works. the clients are clearly returned an array
3 TreeObjects objects. However I cannot actually invoke any functions
on these tree objects. This is the current definition of TreeObject:

When a WebService returns an Object to the calling program, it is sending the
data needed to create such an object. The data is being passed as XML. For the
calling program to use it, it must have the class definition of that object
available. It then creates a new instance of that class, and uses the data
received from the web service to initialize it. There is no sense in which you
are actually sending a functional object to the calling program.

Typically you would have a dll or similar that defines the class, with
properties identified as serializable, which is used by both the web service and
the calling program. When the web service is asked to return an instance of this
class, it returns as XML the values of the serializable properties. Then the
calling program creates an instance of the same class, and uses the serialized
XML data to make it the same as the one the web service used.

A good example is a Dataset, a class which both the web service and the calling
program can create. The web service can then be used to pass data serialized as
XML back and forth between a Dataset on the client and a Dataset on the server.
So essentially I have to mirror all the objects locally (with the
exception of the service itself)? They are not automatically generated
for me by the WSDL? On top of this, it must then reduce the entire
service to a single interface wall...effectively making SOAP identical
to XML-RPC with no benefits at all since I either break encapsulation,
moving entire objects and their contents to the client for processing,
or I have to pass the object data backwards and forwards like a C
style, completely un-object-oriented application?

Surely this is not correct is it?
Jun 27 '08 #5
On May 6, 12:31 pm, Phillip Taylor <Phillip.Ross.Tay...@gmail.com>
wrote:
On May 6, 4:42 pm, "Steve Gerrard" <mynameh...@comcast.netwrote:
Phillip Taylor wrote:
<WebMethod()_
Public Function getCustomer() As TreeObject()
Dim t1 As New TreeObject
Dim t2 As New TreeObject
Dim t3 As New TreeObject
Dim arr(2) As TreeObject
arr(0) = t1
arr(1) = t2
arr(2) = t3
Return arr
End Function
End Class
As you can see my function returns an object of type "TreeObject" and
when you run this it works. the clients are clearly returned an array
3 TreeObjects objects. However I cannot actually invoke any functions
on these tree objects. This is the current definition of TreeObject:
When a WebService returns an Object to the calling program, it is sending the
data needed to create such an object. The data is being passed as XML. For the
calling program to use it, it must have the class definition of that object
available. It then creates a new instance of that class, and uses the data
received from the web service to initialize it. There is no sense in which you
are actually sending a functional object to the calling program.
Typically you would have a dll or similar that defines the class, with
properties identified as serializable, which is used by both the web service and
the calling program. When the web service is asked to return an instance of this
class, it returns as XML the values of the serializable properties. Then the
calling program creates an instance of the same class, and uses the serialized
XML data to make it the same as the one the web service used.
A good example is a Dataset, a class which both the web service and the calling
program can create. The web service can then be used to pass data serialized as
XML back and forth between a Dataset on the client and a Dataset on the server.

So essentially I have to mirror all the objects locally (with the
exception of the service itself)? They are not automatically generated
for me by the WSDL? On top of this, it must then reduce the entire
service to a single interface wall...effectively making SOAP identical
to XML-RPC with no benefits at all since I either break encapsulation,
moving entire objects and their contents to the client for processing,
or I have to pass the object data backwards and forwards like a C
style, completely un-object-oriented application?

Surely this is not correct is it?
Unfortunately, you're trying to do something that is not possible with
web services. The purpose of a SOAP Web service (which is what
the .NET 2.0 Web services are) is to serve SOAP formatted XML, not
objects. They only pretend to be objects because Visual Studio / .NET
is "smart" enough to interpret SOAP formatted XML into proxy classes.
These proxy classes only contain property structures, not methods.

Basically, the normal flow for modifying object through a web service
is as follows:

1) User requests an item
2) Service handle requests, loads the item, and sends it to the user
3) User modifies properties of the item
4) User calls a Save web method and passes in the item
5) Service validates the property values and saves the item

As you see, the only time a user gets access to methods is through the
web service and not the object itself. It takes some getting used to,
but it isn't a very complicated concept, and is much, much more secure
than sending over your code. Just remember that the web service should
act as the presentation layer, and just call directly into your
business objects.

Thanks,

Seth Rowe [MVP]
Jun 27 '08 #6
On May 6, 7:02 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:
On May 6, 12:31 pm, Phillip Taylor <Phillip.Ross.Tay...@gmail.com>
wrote:
On May 6, 4:42 pm, "Steve Gerrard" <mynameh...@comcast.netwrote:
Phillip Taylor wrote:
<WebMethod()_
Public Function getCustomer() As TreeObject()
Dim t1 As New TreeObject
Dim t2 As New TreeObject
Dim t3 As New TreeObject
Dim arr(2) As TreeObject
arr(0) = t1
arr(1) = t2
arr(2) = t3
Return arr
End Function
End Class
As you can see my function returns an object of type "TreeObject" and
when you run this it works. the clients are clearly returned an array
3 TreeObjects objects. However I cannot actually invoke any functions
on these tree objects. This is the current definition of TreeObject:
When a WebService returns an Object to the calling program, it is sending the
data needed to create such an object. The data is being passed as XML. For the
calling program to use it, it must have the class definition of that object
available. It then creates a new instance of that class, and uses the data
received from the web service to initialize it. There is no sense in which you
are actually sending a functional object to the calling program.
Typically you would have a dll or similar that defines the class, with
properties identified as serializable, which is used by both the web service and
the calling program. When the web service is asked to return an instance of this
class, it returns as XML the values of the serializable properties. Then the
calling program creates an instance of the same class, and uses the serialized
XML data to make it the same as the one the web service used.
A good example is a Dataset, a class which both the web service and the calling
program can create. The web service can then be used to pass data serialized as
XML back and forth between a Dataset on the client and a Dataset on the server.
So essentially I have to mirror all the objects locally (with the
exception of the service itself)? They are not automatically generated
for me by the WSDL? On top of this, it must then reduce the entire
service to a single interface wall...effectively making SOAP identical
to XML-RPC with no benefits at all since I either break encapsulation,
moving entire objects and their contents to the client for processing,
or I have to pass the object data backwards and forwards like a C
style, completely un-object-oriented application?
Surely this is not correct is it?

Unfortunately, you're trying to do something that is not possible with
web services. The purpose of a SOAP Web service (which is what
the .NET 2.0 Web services are) is to serve SOAP formatted XML, not
objects. They only pretend to be objects because Visual Studio / .NET
is "smart" enough to interpret SOAP formatted XML into proxy classes.
These proxy classes only contain property structures, not methods.

Basically, the normal flow for modifying object through a web service
is as follows:

1) User requests an item
2) Service handle requests, loads the item, and sends it to the user
3) User modifies properties of the item
4) User calls a Save web method and passes in the item
5) Service validates the property values and saves the item

As you see, the only time a user gets access to methods is through the
web service and not the object itself. It takes some getting used to,
but it isn't a very complicated concept, and is much, much more secure
than sending over your code. Just remember that the web service should
act as the presentation layer, and just call directly into your
business objects.

Thanks,

Seth Rowe [MVP]
I don't want to come across as stupid by reiterating the question but
you are telling me that SOAP is nothing more than XML-RPC. That there
is a wall of functions (like a C style API) that return simple types
or structures and I still question this. I *believe* that with SOAP I
can return references to instance objects. I believe I can *somehow*
(possibly with the use of a proxy or a stub) invoke functions on the
client, which is wrapped up in a SOAP request and translated to an
actual invocation and running of the object instances method on the
server side. You are suggesting this is all that is possible:

SERVER SIDE

int CreateNewObject( ... ) //returns an ID
string GetName (int uniqueId)

CLIENT SIDE

int myObjectId = CreateNewObject ()
string name = GetName( myObjectId )

( A C style wall of functions. The server needs to take the unique Id
and find the real object and invoke the function on it manually).

I actually believe this is possible with SOAP

SERVER SIDE

Object CreateNewObject (...)

CLIENT SIDE

Object o = new Object
string name = o.GetName() //Get name runs on the server, and the
result is specific to the instance in question.

--

Am I delusional? Can't this be done? I would appreciate it if a few
people could confirm or deny this. I'm sorry to ask after I already
got a reply but I'm still not sure how SOAP Servers are developed and
I would like this issue cleared up. Is what I have described possible
or not?
Jun 27 '08 #7
I don't want to come across as stupid by reiterating the question but
you are telling me that SOAP is nothing more than XML-RPC.
Yes, SOAP is the successor to XML-RPC, and like XML-RPC it returns
simple objects which are nothing more than a set of properties (no
methods).
That there
is a wall of functions (like a C style API) that return simple types
or structures
If by "simple types or structures" you mean objects with only
properties than you are correct.
and I still question this.
Which is fine, I'll try to explain as best I can.
I *believe* that with SOAP I
can return references to instance objects.
AFAIK, you cannot return references to server side objects through
the .NET 2.0 SOAP Web Services.
I believe I can *somehow*
(possibly with the use of a proxy or a stub) invoke functions on the
client, which is wrapped up in a SOAP request and translated to an
actual invocation and running of the object instances method on the
server side.
The only way to invoke functions is to call them through the web
service using a SOAP formatted request. There is no "magic"
translation that happens that gives the client the ability to invoke
methods on the object. If I confused you by talking about proxy
classes earlier than let me rephrase - proxy classes are just very
simple objects (properties only) that .NET creates for you to give you
compile time support. All that happens is that the framework reads the
WSDL, pulls out the property structure and does a simple code gen to
create the classes. You'll notice that you'll also lose any
functionality in the properties (such as validation code), they become
simple get..set.. pairs.
You are suggesting this is all that is possible:
Nope. I'm saying if you want to invoke functions on a web service you
must call them through the web service, not the objects served by the
web service.

Take a look at this simple, pseudocode, example on how to use a
service.

Here's the Web Service code:

////////////////
<WebMethod()_
Public Function GetProgrammerByBadgeId(badgeId as integer) As
Programmer
Return New Programmer(badgeId)
End Function

<WebMethod()_
Public Sub SaveProgrammer(programmer as Programmer)
'// We get the Programmer's methods back
programmer.Save()
End Sub
///////////////

And the code for the programmer class:

//////////////
Public Class Programmer

Public Sub New()

End Sub

Public Sub New(badgeId as Integer)
Me.New()

Me.BadgeId = badgeId
Me.Load()
End Sub

'// I'm too lazy to type these out, they are standard properties
Public Property BadgeId As Integer()
Public Property Name As String()
Public Property FavoriteLanguage As String()

Private Sub Load()
'// Load the object from the data access layer
DALC.Load(Me, badgeId)
End Sub

Private Sub Save()
'// Save the object through the data access layer
DALC.Save(Me)
End Sub

End Class
/////////////

This is the client side code:

///////////////
'// Instantiate a new web service
Using service As New ProgrammersService()
Dim programmer As ProgrammersService.Programmer =
service.GetProgrammerByBadgeId(999)

Console.WriteLine("The Programmer's Name is {0}", programmer.Name)
'// Prints "Seth Rowe"
Console.WriteLine("The Programmer's preferred language is {0}",
programmer.PreferredLanguage) '// Prints C#

'// Since C# isn't my favorite language, we need to update the
database
programmer.PreferredLanguage = "VB.NET"

'// That call only sets the client side property value, we now
need to save the object back
service.SaveProgrammer(programmer)
End Using
///////////////

Hopefully that makes a little more sense on how you should be using
web services. Basically you just get the object, do any client side
processing with the properties, and then save the object back to the
web service. If you're really, really stuck and can't figure out how
to implement this pattern with your CustomerService object, let me
know and I'll try to help.

Thanks,

Seth Rowe [MVP]
Jun 27 '08 #8
Phillip Taylor wrote:
server side. You are suggesting this is all that is possible:

SERVER SIDE

int CreateNewObject( ... ) //returns an ID
string GetName (int uniqueId)

CLIENT SIDE

int myObjectId = CreateNewObject ()
string name = GetName( myObjectId )

( A C style wall of functions. The server needs to take the unique Id
and find the real object and invoke the function on it manually).

I actually believe this is possible with SOAP

SERVER SIDE

Object CreateNewObject (...)

CLIENT SIDE

Object o = new Object
string name = o.GetName() //Get name runs on the server, and the
result is specific to the instance in question.
The more likely scenario, given your intentionally simple example:

SERVER:
GetAnObject() As MyClass
' returns, as XML, an Integer and a String

SaveObject(Obj As MyClass)
'saves the passed object

CLIENT:
Dim o As MyClass = ws.GetAnObject()
' MyClass is a generated type on the client end
' containing properties, but no code
x = o.ID
y = o.ObjName

o.ObjName = "New Name"
ws.SaveObject(o)

On the server side, MyClass may be a full blown class, with all sorts of things
going on inside, or just a type with some properties.
On the client, it can be the typical auto-generated shell class, with just a
matching set of properties, or the client can create a full blown object, and
use the passed data to initialize it.

As far as what goes over the wire between the two, though, it is XML, meaning
some nested structure of data values. It is the equivalent of serializing the
object to a file, and then recreating the object at the other end from that
stored data.
Jun 27 '08 #9
On May 7, 12:54 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:
I don't want to come across as stupid by reiterating the question but
you are telling me that SOAP is nothing more than XML-RPC.

Yes, SOAP is the successor to XML-RPC, and like XML-RPC it returns
simple objects which are nothing more than a set of properties (no
methods).
That there
is a wall of functions (like a C style API) that return simple types
or structures

If by "simple types or structures" you mean objects with only
properties than you are correct.
and I still question this.

Which is fine, I'll try to explain as best I can.
I *believe* that with SOAP I
can return references to instance objects.

AFAIK, you cannot return references to server side objects through
the .NET 2.0 SOAP Web Services.
I believe I can *somehow*
(possibly with the use of a proxy or a stub) invoke functions on the
client, which is wrapped up in a SOAP request and translated to an
actual invocation and running of the object instances method on the
server side.

The only way to invoke functions is to call them through the web
service using a SOAP formatted request. There is no "magic"
translation that happens that gives the client the ability to invoke
methods on the object. If I confused you by talking about proxy
classes earlier than let me rephrase - proxy classes are just very
simple objects (properties only) that .NET creates for you to give you
compile time support. All that happens is that the framework reads the
WSDL, pulls out the property structure and does a simple code gen to
create the classes. You'll notice that you'll also lose any
functionality in the properties (such as validation code), they become
simple get..set.. pairs.
You are suggesting this is all that is possible:

Nope. I'm saying if you want to invoke functions on a web service you
must call them through the web service, not the objects served by the
web service.

Take a look at this simple, pseudocode, example on how to use a
service.

Here's the Web Service code:

////////////////
<WebMethod()_
Public Function GetProgrammerByBadgeId(badgeId as integer) As
Programmer
Return New Programmer(badgeId)
End Function

<WebMethod()_
Public Sub SaveProgrammer(programmer as Programmer)
'// We get the Programmer's methods back
programmer.Save()
End Sub
///////////////

And the code for the programmer class:

//////////////
Public Class Programmer

Public Sub New()

End Sub

Public Sub New(badgeId as Integer)
Me.New()

Me.BadgeId = badgeId
Me.Load()
End Sub

'// I'm too lazy to type these out, they are standard properties
Public Property BadgeId As Integer()
Public Property Name As String()
Public Property FavoriteLanguage As String()

Private Sub Load()
'// Load the object from the data access layer
DALC.Load(Me, badgeId)
End Sub

Private Sub Save()
'// Save the object through the data access layer
DALC.Save(Me)
End Sub

End Class
/////////////

This is the client side code:

///////////////
'// Instantiate a new web service
Using service As New ProgrammersService()
Dim programmer As ProgrammersService.Programmer =
service.GetProgrammerByBadgeId(999)

Console.WriteLine("The Programmer's Name is {0}", programmer.Name)
'// Prints "Seth Rowe"
Console.WriteLine("The Programmer's preferred language is {0}",
programmer.PreferredLanguage) '// Prints C#

'// Since C# isn't my favorite language, we need to update the
database
programmer.PreferredLanguage = "VB.NET"

'// That call only sets the client side property value, we now
need to save the object back
service.SaveProgrammer(programmer)
End Using
///////////////

Hopefully that makes a little more sense on how you should be using
web services. Basically you just get the object, do any client side
processing with the properties, and then save the object back to the
web service. If you're really, really stuck and can't figure out how
to implement this pattern with your CustomerService object, let me
know and I'll try to help.

Thanks,

Seth Rowe [MVP]
Thank you for taking the time out to reply. I really mean that. What
you saying makes complete sense. I got the impression that if I passed
an object back from a web service, that it became a webservice itself
- hense I could suddenly call member methods on it - with the real
logic on the server side... but forget it... I was clearly confused
and completely delusional. I think I have better understanding of what
SOAP is now.

Thank you for clearing this up.
Jun 27 '08 #10
On May 7, 11:37 am, Phillip Taylor <Phillip.Ross.Tay...@gmail.com>
wrote:
On May 7, 12:54 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:
I don't want to come across as stupid by reiterating the question but
you are telling me that SOAP is nothing more than XML-RPC.
Yes, SOAP is the successor to XML-RPC, and like XML-RPC it returns
simple objects which are nothing more than a set of properties (no
methods).
That there
is a wall of functions (like a C style API) that return simple types
or structures
If by "simple types or structures" you mean objects with only
properties than you are correct.
and I still question this.
Which is fine, I'll try to explain as best I can.
I *believe* that with SOAP I
can return references to instance objects.
AFAIK, you cannot return references to server side objects through
the .NET 2.0 SOAP Web Services.
I believe I can *somehow*
(possibly with the use of a proxy or a stub) invoke functions on the
client, which is wrapped up in a SOAP request and translated to an
actual invocation and running of the object instances method on the
server side.
The only way to invoke functions is to call them through the web
service using a SOAP formatted request. There is no "magic"
translation that happens that gives the client the ability to invoke
methods on the object. If I confused you by talking about proxy
classes earlier than let me rephrase - proxy classes are just very
simple objects (properties only) that .NET creates for you to give you
compile time support. All that happens is that the framework reads the
WSDL, pulls out the property structure and does a simple code gen to
create the classes. You'll notice that you'll also lose any
functionality in the properties (such as validation code), they become
simple get..set.. pairs.
You are suggesting this is all that is possible:
Nope. I'm saying if you want to invoke functions on a web service you
must call them through the web service, not the objects served by the
web service.
Take a look at this simple, pseudocode, example on how to use a
service.
Here's the Web Service code:
////////////////
<WebMethod()_
Public Function GetProgrammerByBadgeId(badgeId as integer) As
Programmer
Return New Programmer(badgeId)
End Function
<WebMethod()_
Public Sub SaveProgrammer(programmer as Programmer)
'// We get the Programmer's methods back
programmer.Save()
End Sub
///////////////
And the code for the programmer class:
//////////////
Public Class Programmer
Public Sub New()
End Sub
Public Sub New(badgeId as Integer)
Me.New()
Me.BadgeId = badgeId
Me.Load()
End Sub
'// I'm too lazy to type these out, they are standard properties
Public Property BadgeId As Integer()
Public Property Name As String()
Public Property FavoriteLanguage As String()
Private Sub Load()
'// Load the object from the data access layer
DALC.Load(Me, badgeId)
End Sub
Private Sub Save()
'// Save the object through the data access layer
DALC.Save(Me)
End Sub
End Class
/////////////
This is the client side code:
///////////////
'// Instantiate a new web service
Using service As New ProgrammersService()
Dim programmer As ProgrammersService.Programmer =
service.GetProgrammerByBadgeId(999)
Console.WriteLine("The Programmer's Name is {0}", programmer.Name)
'// Prints "Seth Rowe"
Console.WriteLine("The Programmer's preferred language is {0}",
programmer.PreferredLanguage) '// Prints C#
'// Since C# isn't my favorite language, we need to update the
database
programmer.PreferredLanguage = "VB.NET"
'// That call only sets the client side property value, we now
need to save the object back
service.SaveProgrammer(programmer)
End Using
///////////////
Hopefully that makes a little more sense on how you should be using
web services. Basically you just get the object, do any client side
processing with the properties, and then save the object back to the
web service. If you're really, really stuck and can't figure out how
to implement this pattern with your CustomerService object, let me
know and I'll try to help.
Thanks,
Seth Rowe [MVP]

Thank you for taking the time out to reply. I really mean that. What
you saying makes complete sense. I got the impression that if I passed
an object back from a web service, that it became a webservice itself
- hense I could suddenly call member methods on it - with the real
logic on the server side... but forget it... I was clearly confused
and completely delusional. I think I have better understanding of what
SOAP is now.

Thank you for clearing this up.
No problem - I take pride in my ability to get people to say they are
delusional.

:-)

Seriously though, I'm glad I helped you out.

Thanks,

Seth Rowe [MVP]
Jun 27 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jens Hibbeler | last post by:
Hello, I am trying to write a Webservice with Borland C++ Builder 6. I use the WSDL importer but I have no idea how to acess the Webservice. I have tried the following: The WSDL File is...
5
by: hellrazor | last post by:
Hi, (new to webservices here) Is it possible to access a class instance variable defined in a webservice? I want to access this variable, in addition to the data being returned by the . so...
2
by: author | last post by:
Newbie Q... When I hit the "ws.asmx" in a browser, I get "Parser Error Message: Could not create type 'Service1'" ?? If I use the file "ws_ok.asmx" (without codebehind, but same code), I get...
0
by: Rene Ruppert | last post by:
Hi, On the web I found a simple sample/tutorial for a webservice, some kind of chat software. I implemented the server and the client. When I run the client form on the host PC everything works...
1
by: gilad.kapel | last post by:
Hi Some background: working with VS 2005 + Win2003 + IIS6. I have a webservice that creates (if the directory doesn't exist the webservice creates it) a directory "Temp" under the webservice...
1
by: toudidel | last post by:
What can be named webservice? Is asp script receiving by POST method some xml data, performing and responding result, webservice or not yet? Must it be described with WSDL or not (if i want to name...
5
by: Andy | last post by:
Hi, below is simple webservice wich I'd like to test in my local host and when I put http://localhost/test.asmx I'm getting this error: XML Parsing Error: no element found Location:...
2
by: cj | last post by:
<System.Web.Services.WebService(Name:="CJ's Service", Description:="Testing 123", Namespace:="http://myco.com/cj/one")_...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.