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 Boris Klug <bo...@debeka.de> on 2011/01/20 07:58:57 UTC

[Axis2] Create new client stubs on every call?

Hi,

I have one question regarding the handling of the generated Java client 
code.

To call a web service, I use the following code:

       AServiceStub stub = new AServiceStub("http://....");
       response = stub.methodeToCall(paramIn);

My question is: Do I have to create the stub every time when I call a 
webservice or can I create the stub only once and use it over and over 
again? If I can reuse the stub, whats about mutiple thread calling web 
services? What is the best practice?

Thanks in advance for your help.

Mit freundlichen Grüßen

Boris Klug

-- 
Boris Klug
Debeka-Hauptverwaltung
Abteilung BO/Q
Ferdinand-Sauerbruch-Str. 18
56058 Koblenz

Telefon: (0261) 498-3806
Telefax: (0261) 498-1541

E-Mail: Boris.Klug@debeka.de
Internet: www.debeka.de

Debeka Krankenversicherungsverein a. G., AmtsG Koblenz: HRB 125
Debeka Lebensversicherungsverein a. G., AmtsG Koblenz: HRB 141
Debeka Allgemeine Versicherung AG, AmtsG Koblenz: HRB 2300
Debeka Pensionskasse AG, AmtsG Koblenz: HRB 6683
Vorstand: Uwe Laue (Vorsitzender), Rolf Florian, Roland Weber,
Thomas Brahm, Dr. Peter Görg
Aufsichtsratsvorsitzender: Peter Greisler
Sitz Koblenz am Rhein

Debeka Bausparkasse Aktiengesellschaft, Amtsgericht Koblenz: HRB 1114
Vorstand: Jörg Phlippen, Dirk Botzem
Aufsichtsratsvorsitzender: Peter Greisler
Sitz Koblenz am Rhein

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: [Axis2] Create new client stubs on every call?

Posted by Jorge Medina <ce...@gmail.com>.
I believe we had a similar problem.
I believe this occurred when we enabled reuse of the underlying http
client (since we use SSL and we wanted to avoid the cost of
establishing the secure channel)

http://axis.apache.org/axis2/java/core/docs/http-transport.html#reusing_httpclient_object

I can't remember the details, I believe the requests that were
occurring in several threads were being serialized in a single HTTP
connection.
Creating a stub per thread solved the problem.


On Tue, Jan 25, 2011 at 5:12 PM, David Rees <dr...@gmail.com> wrote:
> On Wed, Jan 19, 2011 at 11:53 PM, Dennis Sosnoski <dm...@sosnoski.com> wrote:
>> The stubs are reusable, but not reentrant - so if you're running
>> multiple threads you'll want to either create a new one each time
>> (higher overhead), cache them per thread, or synchronize around each use
>> (only if there's not much use, of course - in which case you're probably
>> better off creating a new one each time anyway).
>
> Wait - so are you saying (stubs are not reentrant) that if you
> maintain a common pool of stubs that gets used across multiple threads
> - that is not supported?
>
> Because I've been doing that successfully for a LONG time now.
>
> -Dave
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: [Axis2] Create new client stubs on every call?

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
On 01/26/2011 11:12 AM, David Rees wrote:
> On Wed, Jan 19, 2011 at 11:53 PM, Dennis Sosnoski <dm...@sosnoski.com> wrote:
>   
>> The stubs are reusable, but not reentrant - so if you're running
>> multiple threads you'll want to either create a new one each time
>> (higher overhead), cache them per thread, or synchronize around each use
>> (only if there's not much use, of course - in which case you're probably
>> better off creating a new one each time anyway).
>>     
> Wait - so are you saying (stubs are not reentrant) that if you
> maintain a common pool of stubs that gets used across multiple threads
> - that is not supported?
>
> Because I've been doing that successfully for a LONG time now.
>   

Just noticed this reply on an earlier thread.

If you're using a pool of stubs that's different from trying to share a
single stub across multiple threads. However, based on what I've seen in
the code you still need to have a memory barrier (i.e., a
synchronization) somewhere in the process of getting the stub for a
thread. Normally your pool would use synchronization as part of the
allocation and deallocation, so that should not be a problem.

That said, a lot of code works fine without synchronization as long as
it's executing on processors with a uniform memory architecture (because
each thread "sees" the other threads' changes automatically). But when
you deploy code with incomplete synchronization to servers with multiple
processors and multiple levels of caching it can cause bizarre crashes.

  - Dennis


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: [Axis2] Create new client stubs on every call?

Posted by David Rees <dr...@gmail.com>.
On Wed, Jan 19, 2011 at 11:53 PM, Dennis Sosnoski <dm...@sosnoski.com> wrote:
> The stubs are reusable, but not reentrant - so if you're running
> multiple threads you'll want to either create a new one each time
> (higher overhead), cache them per thread, or synchronize around each use
> (only if there's not much use, of course - in which case you're probably
> better off creating a new one each time anyway).

Wait - so are you saying (stubs are not reentrant) that if you
maintain a common pool of stubs that gets used across multiple threads
- that is not supported?

Because I've been doing that successfully for a LONG time now.

-Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: [Axis2] Create new client stubs on every call?

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Hi Boris,

The stubs are reusable, but not reentrant - so if you're running
multiple threads you'll want to either create a new one each time
(higher overhead), cache them per thread, or synchronize around each use
(only if there's not much use, of course - in which case you're probably
better off creating a new one each time anyway).

  - Dennis


On 01/20/2011 07:58 PM, Boris Klug wrote:
> Hi,
>
> I have one question regarding the handling of the generated Java
> client code.
>
> To call a web service, I use the following code:
>
>       AServiceStub stub = new AServiceStub("http://....");
>       response = stub.methodeToCall(paramIn);
>
> My question is: Do I have to create the stub every time when I call a
> webservice or can I create the stub only once and use it over and over
> again? If I can reuse the stub, whats about mutiple thread calling web
> services? What is the best practice?
>
> Thanks in advance for your help.
>
> Mit freundlichen Grüßen
>
> Boris Klug
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: Axis2, automatically generated WSDL and autodetected URL as wsdl:port location

Posted by Andreas Veithen <an...@gmail.com>.
This is probably related to issue AXIS2-4465. There is some additional
information here:

http://axis.apache.org/axis2/java/core/docs/servlet-transport.html

Note that this applies to Axis2 >= 1.5.3.

Andreas

On Thu, Jan 20, 2011 at 09:28,  <fa...@uniserv.com> wrote:
> Hi,
>
> We have axis2 running with tomcat6. Tomcat is running on the port 8080
> and is connected to an apache server via mod_jk.
> So our axis2 web service is accessable via http on port 80.
>
> The autodetected url in the automatically generated wsdl is almost
> always correct, http://myserver:80/axis2...
>
>
> But sometimes after tomcat restart, the wsdl contains the location like
> http://myserver:8080/axis2...
>
> Even then, the web service is still available via the port 80. But the
> wsdl is not correct.
>
> Why?
> How does axis2 autodetect the url to be used as the location?
> When does it happen? Immediately after the deployment?
> Is it possible, that sometimes, the ajp13 conncetion is not yet
> available, when the wsdl is generated?
> Is wsdl cached?
> How long?
>
> I try to find the way to avoid the wrong port number in the wsdl -
> I could provide some static wsdl in the aar-package, but there are other
> problems caused by this.
>
> So I want to work with the autogenerated wsdl file, but also I want to
> be sure, the autodetected url is always correct.
>
> Thanks!
>
> Best regards,
> Fadila
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Axis2, automatically generated WSDL and autodetected URL as wsdl:port location

Posted by fa...@uniserv.com.
Hi,

We have axis2 running with tomcat6. Tomcat is running on the port 8080
and is connected to an apache server via mod_jk.
So our axis2 web service is accessable via http on port 80.

The autodetected url in the automatically generated wsdl is almost
always correct, http://myserver:80/axis2...


But sometimes after tomcat restart, the wsdl contains the location like
http://myserver:8080/axis2... 

Even then, the web service is still available via the port 80. But the
wsdl is not correct.

Why? 
How does axis2 autodetect the url to be used as the location?
When does it happen? Immediately after the deployment? 
Is it possible, that sometimes, the ajp13 conncetion is not yet
available, when the wsdl is generated? 
Is wsdl cached? 
How long?

I try to find the way to avoid the wrong port number in the wsdl - 
I could provide some static wsdl in the aar-package, but there are other
problems caused by this. 

So I want to work with the autogenerated wsdl file, but also I want to
be sure, the autodetected url is always correct.

Thanks!

Best regards,
Fadila



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org