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 Stefan Schuster <ss...@pironet-ndh.com> on 2005/09/08 10:20:34 UTC
Re: Attachment upload Client to Server, use Handlers?
Hi Alexandre,
I already got the server-side working. The problem is that
a client fails to get the messageContext bevore the first call.
I wonder if I can use handlers on the client and how
to configure them?
BTW. Thanks for the suggestion, it almost helped :-)
Stefan
Alexandre Touret wrote:
> Stefan Schuster wrote:
>
>> Hi everybody,
>>
>> how can I send an attachment from the client to an server without
>> using the DataHandler in the method signature? I tried
>> to get the MessageContext (getCurrentMessageContext()), but it
>> returns null.
>>
>> How can I obtain an messageContext to set the attachment to an
>> message in the client?
>>
>> Thanks in advance,
>>
>> Stefan
>>
>>
>>
> Hello,
> I have an example where the server sends an attachment
>
>
> public SOAPEnvelope extractReport(String _reportName, String _path,
> HashMap _parameters, String _format)
> throws RemoteException {
> trace.info("Extracting report...");
>
> try {
> MessageContext msgContext =
> MessageContext.getCurrentContext();
> Message response = msgContext.getResponseMessage();
> Iterator attachmentsIterator = response.getAttachments();
>
> if (attachmentsIterator == null) {
> trace.fatal("No Support for attachments !");
> throw new SOAPException("No Support for attachments");
> }
> //Crystal Reports Extraction
> ReportBuilder builder =
> ReportFactory.getFactory().getBuilder();
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> ReportFormat format = ReportFormat.getReportFormat(_format);
> final String host =
> ConfigSingleton.getInstance().getConfiguration().getString(Conf.CRYSTAL_HOST);
>
> Exportable export = new ExportableImpl(out, format, host,
> _parameters, _path);
> builder.getReport(export).export();
> ByteArrayInputStream input = new
> ByteArrayInputStream(out.toByteArray());
> AttachmentPart current = response.createAttachmentPart();
> current.setContent(input, format.getContentType());
>
> current.setContentId(_reportName!=null?_reportName:REPORT_CONTENT_ID);
> response.addAttachmentPart(current);
> response.saveChanges();
> return response.getSOAPEnvelope();
> } catch (ReportException e) {
> trace.error(getClass().getName() + ".extractReport():" +
> e.getMessage(), e);
> throw new RemoteException(e.getMessage(), e);
> } catch (SOAPException e) {
> trace.error(getClass().getName() + ".extractReport():" +
> e.getMessage(), e);
> throw new RemoteException(e.getMessage(), e);
> } catch (ConfigurationException e) {
> trace.error(getClass().getName() + ".extractReport():" +
> e.getMessage(), e);
> throw new RemoteException(e.getMessage(), e);
> } finally {
> trace.info("Report extracted");
> }
> }
>
>
> Hope this helps
>
> Alexandre
Re: Attachment upload Client to Server, use Handlers?
Posted by Stefan Schuster <ss...@pironet-ndh.com>.
The client uses Axis. My problem is that in the client, I cannot
get an Message context before the first call to the server through the
stubs. The trace shows a simple NullPointerException in my client.
Stefan
Alexandre Touret wrote:
> Could you send the stack trace
> May be that your client doesnt support attachments ....
>
> Stefan Schuster wrote:
>
>> Hi Alexandre,
>>
>> I already got the server-side working. The problem is that
>> a client fails to get the messageContext bevore the first call.
>> I wonder if I can use handlers on the client and how
>> to configure them?
>>
>> BTW. Thanks for the suggestion, it almost helped :-)
>>
>> Stefan
>
>
>
Re: Attachment upload Client to Server, use Handlers?
Posted by Alexandre Touret <at...@free.fr>.
Could you send the stack trace
May be that your client doesnt support attachments ....
Stefan Schuster wrote:
> Hi Alexandre,
>
> I already got the server-side working. The problem is that
> a client fails to get the messageContext bevore the first call.
> I wonder if I can use handlers on the client and how
> to configure them?
>
> BTW. Thanks for the suggestion, it almost helped :-)
>
> Stefan