You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Andreas Leitner <no...@sbox.tugraz.at> on 2002/08/07 13:19:16 UTC

Sending more than just beans (Best Practice?)

Hi again,

now that I have sessions working correctly I am now trying to implement a simple Client/Server combo.

I understand from the docs that references cannot be transmitted via soap. So that in the following scenario (server side):

class MyService
{
	Person getPersonByName (String name)
	{	
		... lookup person in db and return reference to it...
	}

}
class Person
{
	private String name;
	private String tel;
	public String getName () {return name}
	public String getTel () {return tel}
	public void setName (String name) {this.name = name;}
	public void setTel (String tel) {this.tel = tel;}
}
--

I would get on the client side:
--
class MyService
{
	Person getPersonByName (String name)
	{ ... do proxy stuff ...}
}
--
which is ok, but class Person would carry only public data and no operations.
--
class Person
{
	public String name;
	public String tel;
}
--

Now I can imaging this will work for simple cases, but as classes get more complex, I surely will need more than plain structs. Even if no operations are permitted, a client may not be allowed to set all attributes of an object at will.

Of course such a plain struct has the advantage, that setting an attribute does not require a SOAP call on the other hand.

If I want class Person on the client side to have operations, do I need to write custom serializers/deserializers? How have others solved this problems? Can I combine server webserices - like one webservice for MyService and one for Person, where 'getPersonByName' would somehow return a reference to the WebService 'Person'?

many thanks in advance,
Andreas


Re: Sending more than just beans (Best Practice?)

Posted by Andreas Leitner <no...@sbox.tugraz.at>.
On Wed, Aug 07, 2002 at 09:50:21AM -0700, Ricky Ho wrote:
> At 01:35 PM 8/7/2002 +0200, Andreas Leitner wrote:
> >On Wed, Aug 07, 2002 at 12:27:57PM +0100, Simon Hargreaves wrote:
> If you are using the class autogenerated from the WSDL file, then even 
> custom serializer doesn't help.  Of course, if you define your own "Person" 
> class and use your own custom serializer then it will work.
> Another approach is to write a wrapper class that mirror's the 
> autogenerated Person class and put all your method in the wrapper class.  I 
> think this is the simplest way.
> 
> There is currently NO standard way to return a reference to serviceB from 
> an operation of serviceA.  Of course, an ugly way is to pass the endpoint 
> URL endpoint as a string.


Thanks alot Ricky. I guess I have to think more about it. But your help is very valueable to me.


regards,
Andreas


Re: Sending more than just beans (Best Practice?)

Posted by Ricky Ho <ri...@cisco.com>.
At 01:35 PM 8/7/2002 +0200, Andreas Leitner wrote:
>On Wed, Aug 07, 2002 at 12:27:57PM +0100, Simon Hargreaves wrote:
> > Andreas Leitner wrote:
> >
> > >Hi again,
> > >
> > >now that I have sessions working correctly I am now trying to implement a
> > >simple Client/Server combo.
> > >
> > >I understand from the docs that references cannot be transmitted via 
> soap.
> > >So that in the following scenario (server side):
> > >
> > >class MyService
> > >{
> > >     Person getPersonByName (String name)
> > >     {
> > >             ... lookup person in db and return reference to it...
> > >     }
> > >
> > >}
> > >class Person
> > >{
> > >     private String name;
> > >     private String tel;
> > >     public String getName () {return name}
> > >     public String getTel () {return tel}
> > >     public void setName (String name) {this.name = name;}
> > >     public void setTel (String tel) {this.tel = tel;}
> > >}
> > >--
> > >
> > >I would get on the client side:
> > >--
> > >class MyService
> > >{
> > >     Person getPersonByName (String name)
> > >     { ... do proxy stuff ...}
> > >}
> > >--
> > >which is ok, but class Person would carry only public data and no
> > >operations.
> > >--
> > >class Person
> > >{
> > >     public String name;
> > >     public String tel;
> > >}
> > >--
> > >
> > >
> > Since the client needs to know the class to instantiate it, then the
> > methods are there anyway, they're not transmitted but the methods are
> > common knowledge.
> >
> > Beans need all the properties to be set using getXXX setXXX methods
> > otherwise it's not a bean. Internal state can be read if it's public,
> > and if you don't want to use a bean you can write your own Serializer
> > for that class.
>
>
>Correct in case Server=Axis and Client=Axis. I am sorry I was a bit unclear.
>In case of Server=Axis and Client=.NET the connection is defined via a 
>WSDL file.
>
>I am using the autogenerated WSDL file (the one that I get by appending a 
>'?WSDL' to the services URL).
>In that WSDL file (taken from the above scenario) all information I get 
>about Person is a simple schema, which lists all attributes of Person as a 
>'sequence'. There is of course no way for .NET to make anything more out 
>of that information than a simple class with only attributes.
>
>Is there any way I can force .NET to generate a Stub for Person as 
>detailed as it was generated for MyService?
>
>tia,
>Andreas

If you are using the class autogenerated from the WSDL file, then even 
custom serializer doesn't help.  Of course, if you define your own "Person" 
class and use your own custom serializer then it will work.
Another approach is to write a wrapper class that mirror's the 
autogenerated Person class and put all your method in the wrapper class.  I 
think this is the simplest way.

There is currently NO standard way to return a reference to serviceB from 
an operation of serviceA.  Of course, an ugly way is to pass the endpoint 
URL endpoint as a string.

Rgds, Ricky


Re: Sending more than just beans (Best Practice?)

Posted by Andreas Leitner <no...@sbox.tugraz.at>.
On Wed, Aug 07, 2002 at 12:27:57PM +0100, Simon Hargreaves wrote:
> Andreas Leitner wrote:
> 
> >Hi again,
> >
> >now that I have sessions working correctly I am now trying to implement a 
> >simple Client/Server combo.
> >
> >I understand from the docs that references cannot be transmitted via soap. 
> >So that in the following scenario (server side):
> >
> >class MyService
> >{
> >	Person getPersonByName (String name)
> >	{	
> >		... lookup person in db and return reference to it...
> >	}
> >
> >}
> >class Person
> >{
> >	private String name;
> >	private String tel;
> >	public String getName () {return name}
> >	public String getTel () {return tel}
> >	public void setName (String name) {this.name = name;}
> >	public void setTel (String tel) {this.tel = tel;}
> >}
> >--
> >
> >I would get on the client side:
> >--
> >class MyService
> >{
> >	Person getPersonByName (String name)
> >	{ ... do proxy stuff ...}
> >}
> >--
> >which is ok, but class Person would carry only public data and no 
> >operations.
> >--
> >class Person
> >{
> >	public String name;
> >	public String tel;
> >}
> >--
> > 
> >
> Since the client needs to know the class to instantiate it, then the 
> methods are there anyway, they're not transmitted but the methods are 
> common knowledge.
> 
> Beans need all the properties to be set using getXXX setXXX methods 
> otherwise it's not a bean. Internal state can be read if it's public, 
> and if you don't want to use a bean you can write your own Serializer 
> for that class.


Correct in case Server=Axis and Client=Axis. I am sorry I was a bit unclear.
In case of Server=Axis and Client=.NET the connection is defined via a WSDL file.

I am using the autogenerated WSDL file (the one that I get by appending a '?WSDL' to the services URL).
In that WSDL file (taken from the above scenario) all information I get about Person is a simple schema, which lists all attributes of Person as a 'sequence'. There is of course no way for .NET to make anything more out of that information than a simple class with only attributes.

Is there any way I can force .NET to generate a Stub for Person as detailed as it was generated for MyService?

tia,
Andreas


Re: Sending more than just beans (Best Practice?)

Posted by Simon Hargreaves <si...@openthought.com>.
Andreas Leitner wrote:

>Hi again,
>
>now that I have sessions working correctly I am now trying to implement a simple Client/Server combo.
>
>I understand from the docs that references cannot be transmitted via soap. So that in the following scenario (server side):
>
>class MyService
>{
>	Person getPersonByName (String name)
>	{	
>		... lookup person in db and return reference to it...
>	}
>
>}
>class Person
>{
>	private String name;
>	private String tel;
>	public String getName () {return name}
>	public String getTel () {return tel}
>	public void setName (String name) {this.name = name;}
>	public void setTel (String tel) {this.tel = tel;}
>}
>--
>
>I would get on the client side:
>--
>class MyService
>{
>	Person getPersonByName (String name)
>	{ ... do proxy stuff ...}
>}
>--
>which is ok, but class Person would carry only public data and no operations.
>--
>class Person
>{
>	public String name;
>	public String tel;
>}
>--
>  
>
Since the client needs to know the class to instantiate it, then the 
methods are there anyway, they're not transmitted but the methods are 
common knowledge.

Beans need all the properties to be set using getXXX setXXX methods 
otherwise it's not a bean. Internal state can be read if it's public, 
and if you don't want to use a bean you can write your own Serializer 
for that class.

Simon...

-- 
---------------------------
http://www.openhistory.net
  free the information
---------------------------