Carlos,

thanx for suggestion, though I described in my post that it's also the way that I'm using now (instantiate new stub for each request, so I could set request attachment on it). BUT, since stubs are thread-safe, I believe they are meant to be used as shared/thread-safe/singleton service, meaning, I should not instantiate new one for each request, but reuse single one. I believe that performance is also much better then. I'm interested in how to achieve setting attachments in such "single/shared" case.

----- Original Message ----- From: "Carlos" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, November 01, 2005 7:03 PM
Subject: Re: Sending attachments using *generated client stubs*?


Vjeran,

When I use the generated stubs to send an attachment we create a new stub for our specific web service. I believe if we then make the attachments to that stub by doing the following...

stub._setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_MIME);
String file = "c:\\test\\abcde.jpg";
DataHandler buildFile = new DataHandler(new FileDataSource(file));
stub.addAttachment(buildFile);

Then this handler is specific to that instance of the stub, and should be thread safe. Someone correct me if I'm wrong.

-Carlos

Vjeran Marcinko wrote:

Hi folks.

As far as I understood, client stubs generated by WSDL2Java are suposed to be used as stateless thread-safe services, meaning, many simultaneous requests can be called on it. Client methods should just see business interface exposed by this stub.

Everything's fine except when I need to send attachments when calling some remote method on this stub. I know attachments can be added to Call object, but using generated stub, I cannot see Call object since everything is hidden behind business interaface ?

How should I do that then?

I know that I can cast stub instance to Stub, and use addAttachment() method on it, but then it isn't thread-safe, since some other thread can do simulateously the same thing, since they all share the same stub instance. To overcome all this, I currently instantiate new stub each time during each method call, set desired attachments before calling business method, but I am sure I'm paying huge performance penalty that way, right?

Regards,
Vjeran


Reply via email to