Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Web service - business objects don't show up

Reply
Thread Tools

Web service - business objects don't show up

 
 
Water Cooler v2
Guest
Posts: n/a
 
      02-28-2006
I create a test Web service like so:

[WebService(Namespace="http://blah.com")]
public class ServiceThingy: System.Web.Services.WebService
{
[WebMethod]
public int ReturnFour()
{
return 4;
}
}


I create another class other than this, like so:

class BusinessObject
{
public string doBusiness()
{
return "Did business. It was nice.";
}
}


I compile.
I make a new Console application project.
I add a Web Reference to this service asmx in my new console
application project.
When I do this:

localhost.

I expect the BusinessObject class also to show up, but it doesn't. The
main service class shows up, though.

Now, earlier on, only a few days ago, I developed a huge Web Service
app with a lot of business objects and all the business object/classes
showed up in the client. What's the deal here? Am I missing something
obvious?

 
Reply With Quote
 
 
 
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      02-28-2006
Yes.
Notice that the ReturnFour method is attributed with [WebMethod], and that
the doBusiness method is not.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"Water Cooler v2" wrote:

> I create a test Web service like so:
>
> [WebService(Namespace="http://blah.com")]
> public class ServiceThingy: System.Web.Services.WebService
> {
> [WebMethod]
> public int ReturnFour()
> {
> return 4;
> }
> }
>
>
> I create another class other than this, like so:
>
> class BusinessObject
> {
> public string doBusiness()
> {
> return "Did business. It was nice.";
> }
> }
>
>
> I compile.
> I make a new Console application project.
> I add a Web Reference to this service asmx in my new console
> application project.
> When I do this:
>
> localhost.
>
> I expect the BusinessObject class also to show up, but it doesn't. The
> main service class shows up, though.
>
> Now, earlier on, only a few days ago, I developed a huge Web Service
> app with a lot of business objects and all the business object/classes
> showed up in the client. What's the deal here? Am I missing something
> obvious?
>
>

 
Reply With Quote
 
 
 
 
Josh Twist
Guest
Posts: n/a
 
      02-28-2006
The ASMX runtime will add all types exposed in your webmethod to the
WSDL (and thus, in turn, to your client projects when you add web
reference). In this case your WebMethod exposes only an int.

To prove the point create another WebMethod that returns an instance of
your BusinessObject....

However, the process by which objects enter and leave a Web Service is
XmlSerialization - and this is capable of serializing data only - so
your doBusiness() method wouldn't be visible.

It's important to get a grip on all this before venturing too far with
Web Services - so I recommend you read this:
http://msdn.microsoft.com/library/de...howwebmeth.asp,
in particular the section on Mapping XML to Objects.

Good Luck

Josh
http://www.thejoyofcode.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compressing Business Objects through web service Chris Kennedy ASP .Net 1 07-19-2009 01:33 PM
PreLoading Data into Business Objects over a Web Service Chris Kennedy ASP .Net 0 04-17-2009 09:26 PM
Architectual advice on Web Service. DataSet vs Business Objects? Henrik Skak Pedersen ASP .Net Web Services 5 03-27-2006 08:43 PM
InvocationTargetException when calling "new Service()" in Axis web service to call another web service Michael Averstegge Java 0 01-10-2006 11:05 PM
Business Opportunity - Start Your Own VoIP Telephony Service Provider Business ubifone VOIP 0 07-29-2005 07:55 PM



Advertisments