You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Glen Mazza <gl...@gmail.com> on 2009/04/01 00:15:31 UTC

Re: Using DataHandler for attachments

I think you're approaching the problem the wrong way.  The Java DataHandler
class, when being used from the web service provider, would not have any
clue what programming language the client is written in.  It's just XML (and
a MIME attachment) over the wire.  So I think you would need to go to some
help forum for the language that you wish to write your SOAP client in and
ask how you can receive MTOM attachments--i.e., what is C++'s equivalent for
Java's DataHandler.

Glen


Arby wrote:
> 
> Hello,   I have a CXF service running for transferring files that I would
> like to be consumed by a C++ client. Currently I am looking at gSOAP to
> implement the client side but before I start, is there any known way of
> using DataHandler to transfer files from a Java service to a non-Java
> client? I've been digging around for months and any help would be
> appreciated.
> 
> Thanks.
> 

-- 
View this message in context: http://www.nabble.com/Using-DataHandler-for-attachments-tp22810928p22815936.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Using DataHandler for attachments

Posted by Daniel Kulp <dk...@apache.org>.
On Tue March 31 2009 6:49:32 pm Arby wrote:
> Right. So in order to use the Java service's upload method, I have to
> provide a DataHandler object (that references a file) and from what I
> understand, DataHandler is just a wrapper for an InputStream. So if I were
> to construct my own DataHandler class in C++ and pass an input stream to
> the Java Service's upload method, it should be ok. But how would the Java
> service cast the InputStream into a DataHandler object before processing
> the upload request? Also, I can't use Base64String because the attachments
> are quite large and the buffer would easily overflow. Has
> anyone successfully developed a C++ client for a Java service that uses
> MTOM for file transfer? Any help would be appreciated.

Is this a "wsdl first" thing or a "java first" thing?    Basically, JAXB can 
definitely use a DataHandler instead of byte[] for the mtom things, you just 
kind of need to let it know.

For wsdl first, you normally just need to update the element for the 
base64binary type to look something like:

<element name="attachinfo" type="xsd:base64Binary" 
xmime:expectedContentTypes="application/octet-stream"/>

JAXB will then generate a DataHandler type for it.   If mtom is turned on, 
those would then be attached via the mtom mechanisms and streamed (if 
possible).


Dan





> On Tue, Mar 31, 2009 at 3:15 PM, Glen Mazza <gl...@gmail.com> wrote:
> > I think you're approaching the problem the wrong way.  The Java
> > DataHandler class, when being used from the web service provider, would
> > not have any clue what programming language the client is written in. 
> > It's just XML (and
> > a MIME attachment) over the wire.  So I think you would need to go to
> > some help forum for the language that you wish to write your SOAP client
> > in and ask how you can receive MTOM attachments--i.e., what is C++'s
> > equivalent for
> > Java's DataHandler.
> >
> > Glen
> >
> > Arby wrote:
> > > Hello,   I have a CXF service running for transferring files that I
> > > would like to be consumed by a C++ client. Currently I am looking at
> > > gSOAP to implement the client side but before I start, is there any
> > > known way of using DataHandler to transfer files from a Java service to
> > > a non-Java client? I've been digging around for months and any help
> > > would be appreciated.
> > >
> > > Thanks.
> >
> > --
> > View this message in context:
> > http://www.nabble.com/Using-DataHandler-for-attachments-tp22810928p228159
> >36.html Sent from the cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Using DataHandler for attachments

Posted by Andrew Clegg <an...@nervechannel.com>.
For clients that don't support attachments properly, you can always
save the file to a temporary static location on your webserver with a
non-guessable name, and send a URL instead. Then have a scheduled task
that removes such files older than a certain age.

I believe we've done this before with older services in the Perl
world. Bit of a hack but it works...

Andrew.

2009/4/1 Arby <br...@gmail.com>:
> I understand where you are coming from and I've posted in gSOAP's forums as
> well to ask about some hints regarding this problem since gSOAP is suppose
> to be fully compliant with the MTOM standard for transferring files.  Is
> there any other C++ SOAP client that you would recommend?
> I thought perhaps if someone else has come across this issue before, it
> might be useful to post here as well.
>
> Before I was using Base64String to transfer small files - the Java service's
> upload method would accept a binary file encoded to a Base64 string and it's
> very trivial to create a Base64 string in C++ so there were no problems.
> However, that approach does not work for large files because the entire file
> has to be read into a buffer before encoding it into a Base64 string.
>
> Thanks for your responses.
>
> On Tue, Mar 31, 2009 at 6:09 PM, Glen Mazza <gl...@gmail.com> wrote:
>
>>
>> Java InputStream <> C++ InputStream (assuming the latter exists).  Your way
>> of thinking still seems strange:
>> "successfully developed a C++ client for a Java service that uses MTOM"
>> should not be the issue.  The real question should be: "successfully
>> developed a C++ client for a web service that uses MTOM".
>>
>> Your C++ client needs to be able to receive (or send) an MTOM attachment
>> with zero knowledge of the programming language being used to create the
>> web
>> service provider.  If you need to know, or otherwise are factoring into
>> consideration, the programming language the web service provider was
>> implemented in, I don't think you're approaching the problem correctly.
>> Your question still seems best for a C++ web services forum (unless someone
>> here has experience writing C++ SOAP clients.)
>>
>> Glen
>>
>>
>> Arby wrote:
>> >
>> > Right. So in order to use the Java service's upload method, I have to
>> > provide a DataHandler object (that references a file) and from what I
>> > understand, DataHandler is just a wrapper for an InputStream. So if I
>> were
>> > to construct my own DataHandler class in C++ and pass an input stream to
>> > the
>> > Java Service's upload method, it should be ok. But how would the Java
>> > service cast the InputStream into a DataHandler object before processing
>> > the
>> > upload request? Also, I can't use Base64String because the attachments
>> are
>> > quite large and the buffer would easily overflow. Has
>> > anyone successfully developed a C++ client for a Java service that uses
>> > MTOM
>> > for file transfer? Any help would be appreciated.
>> >
>> > On Tue, Mar 31, 2009 at 3:15 PM, Glen Mazza <gl...@gmail.com>
>> wrote:
>> >
>> >>
>> >> I think you're approaching the problem the wrong way.  The Java
>> >> DataHandler
>> >> class, when being used from the web service provider, would not have any
>> >> clue what programming language the client is written in.  It's just XML
>> >> (and
>> >> a MIME attachment) over the wire.  So I think you would need to go to
>> >> some
>> >> help forum for the language that you wish to write your SOAP client in
>> >> and
>> >> ask how you can receive MTOM attachments--i.e., what is C++'s equivalent
>> >> for
>> >> Java's DataHandler.
>> >>
>> >> Glen
>> >>
>> >>
>> >> Arby wrote:
>> >> >
>> >> > Hello,   I have a CXF service running for transferring files that I
>> >> would
>> >> > like to be consumed by a C++ client. Currently I am looking at gSOAP
>> to
>> >> > implement the client side but before I start, is there any known way
>> of
>> >> > using DataHandler to transfer files from a Java service to a non-Java
>> >> > client? I've been digging around for months and any help would be
>> >> > appreciated.
>> >> >
>> >> > Thanks.
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Using-DataHandler-for-attachments-tp22810928p22815936.html
>> >> Sent from the cxf-user mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Using-DataHandler-for-attachments-tp22810928p22817988.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>>
>



-- 
:: http://biotext.org.uk/ ::

Re: Using DataHandler for attachments

Posted by Arby <br...@gmail.com>.
I understand where you are coming from and I've posted in gSOAP's forums as
well to ask about some hints regarding this problem since gSOAP is suppose
to be fully compliant with the MTOM standard for transferring files.  Is
there any other C++ SOAP client that you would recommend?
I thought perhaps if someone else has come across this issue before, it
might be useful to post here as well.

Before I was using Base64String to transfer small files - the Java service's
upload method would accept a binary file encoded to a Base64 string and it's
very trivial to create a Base64 string in C++ so there were no problems.
However, that approach does not work for large files because the entire file
has to be read into a buffer before encoding it into a Base64 string.

Thanks for your responses.

On Tue, Mar 31, 2009 at 6:09 PM, Glen Mazza <gl...@gmail.com> wrote:

>
> Java InputStream <> C++ InputStream (assuming the latter exists).  Your way
> of thinking still seems strange:
> "successfully developed a C++ client for a Java service that uses MTOM"
> should not be the issue.  The real question should be: "successfully
> developed a C++ client for a web service that uses MTOM".
>
> Your C++ client needs to be able to receive (or send) an MTOM attachment
> with zero knowledge of the programming language being used to create the
> web
> service provider.  If you need to know, or otherwise are factoring into
> consideration, the programming language the web service provider was
> implemented in, I don't think you're approaching the problem correctly.
> Your question still seems best for a C++ web services forum (unless someone
> here has experience writing C++ SOAP clients.)
>
> Glen
>
>
> Arby wrote:
> >
> > Right. So in order to use the Java service's upload method, I have to
> > provide a DataHandler object (that references a file) and from what I
> > understand, DataHandler is just a wrapper for an InputStream. So if I
> were
> > to construct my own DataHandler class in C++ and pass an input stream to
> > the
> > Java Service's upload method, it should be ok. But how would the Java
> > service cast the InputStream into a DataHandler object before processing
> > the
> > upload request? Also, I can't use Base64String because the attachments
> are
> > quite large and the buffer would easily overflow. Has
> > anyone successfully developed a C++ client for a Java service that uses
> > MTOM
> > for file transfer? Any help would be appreciated.
> >
> > On Tue, Mar 31, 2009 at 3:15 PM, Glen Mazza <gl...@gmail.com>
> wrote:
> >
> >>
> >> I think you're approaching the problem the wrong way.  The Java
> >> DataHandler
> >> class, when being used from the web service provider, would not have any
> >> clue what programming language the client is written in.  It's just XML
> >> (and
> >> a MIME attachment) over the wire.  So I think you would need to go to
> >> some
> >> help forum for the language that you wish to write your SOAP client in
> >> and
> >> ask how you can receive MTOM attachments--i.e., what is C++'s equivalent
> >> for
> >> Java's DataHandler.
> >>
> >> Glen
> >>
> >>
> >> Arby wrote:
> >> >
> >> > Hello,   I have a CXF service running for transferring files that I
> >> would
> >> > like to be consumed by a C++ client. Currently I am looking at gSOAP
> to
> >> > implement the client side but before I start, is there any known way
> of
> >> > using DataHandler to transfer files from a Java service to a non-Java
> >> > client? I've been digging around for months and any help would be
> >> > appreciated.
> >> >
> >> > Thanks.
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Using-DataHandler-for-attachments-tp22810928p22815936.html
> >> Sent from the cxf-user mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Using-DataHandler-for-attachments-tp22810928p22817988.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>

Re: Using DataHandler for attachments

Posted by Glen Mazza <gl...@gmail.com>.
Java InputStream <> C++ InputStream (assuming the latter exists).  Your way
of thinking still seems strange:
"successfully developed a C++ client for a Java service that uses MTOM"
should not be the issue.  The real question should be: "successfully
developed a C++ client for a web service that uses MTOM".

Your C++ client needs to be able to receive (or send) an MTOM attachment
with zero knowledge of the programming language being used to create the web
service provider.  If you need to know, or otherwise are factoring into
consideration, the programming language the web service provider was
implemented in, I don't think you're approaching the problem correctly. 
Your question still seems best for a C++ web services forum (unless someone
here has experience writing C++ SOAP clients.)

Glen


Arby wrote:
> 
> Right. So in order to use the Java service's upload method, I have to
> provide a DataHandler object (that references a file) and from what I
> understand, DataHandler is just a wrapper for an InputStream. So if I were
> to construct my own DataHandler class in C++ and pass an input stream to
> the
> Java Service's upload method, it should be ok. But how would the Java
> service cast the InputStream into a DataHandler object before processing
> the
> upload request? Also, I can't use Base64String because the attachments are
> quite large and the buffer would easily overflow. Has
> anyone successfully developed a C++ client for a Java service that uses
> MTOM
> for file transfer? Any help would be appreciated.
> 
> On Tue, Mar 31, 2009 at 3:15 PM, Glen Mazza <gl...@gmail.com> wrote:
> 
>>
>> I think you're approaching the problem the wrong way.  The Java
>> DataHandler
>> class, when being used from the web service provider, would not have any
>> clue what programming language the client is written in.  It's just XML
>> (and
>> a MIME attachment) over the wire.  So I think you would need to go to
>> some
>> help forum for the language that you wish to write your SOAP client in
>> and
>> ask how you can receive MTOM attachments--i.e., what is C++'s equivalent
>> for
>> Java's DataHandler.
>>
>> Glen
>>
>>
>> Arby wrote:
>> >
>> > Hello,   I have a CXF service running for transferring files that I
>> would
>> > like to be consumed by a C++ client. Currently I am looking at gSOAP to
>> > implement the client side but before I start, is there any known way of
>> > using DataHandler to transfer files from a Java service to a non-Java
>> > client? I've been digging around for months and any help would be
>> > appreciated.
>> >
>> > Thanks.
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Using-DataHandler-for-attachments-tp22810928p22815936.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Using-DataHandler-for-attachments-tp22810928p22817988.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Using DataHandler for attachments

Posted by Arby <br...@gmail.com>.
Right. So in order to use the Java service's upload method, I have to
provide a DataHandler object (that references a file) and from what I
understand, DataHandler is just a wrapper for an InputStream. So if I were
to construct my own DataHandler class in C++ and pass an input stream to the
Java Service's upload method, it should be ok. But how would the Java
service cast the InputStream into a DataHandler object before processing the
upload request? Also, I can't use Base64String because the attachments are
quite large and the buffer would easily overflow. Has
anyone successfully developed a C++ client for a Java service that uses MTOM
for file transfer? Any help would be appreciated.

On Tue, Mar 31, 2009 at 3:15 PM, Glen Mazza <gl...@gmail.com> wrote:

>
> I think you're approaching the problem the wrong way.  The Java DataHandler
> class, when being used from the web service provider, would not have any
> clue what programming language the client is written in.  It's just XML
> (and
> a MIME attachment) over the wire.  So I think you would need to go to some
> help forum for the language that you wish to write your SOAP client in and
> ask how you can receive MTOM attachments--i.e., what is C++'s equivalent
> for
> Java's DataHandler.
>
> Glen
>
>
> Arby wrote:
> >
> > Hello,   I have a CXF service running for transferring files that I would
> > like to be consumed by a C++ client. Currently I am looking at gSOAP to
> > implement the client side but before I start, is there any known way of
> > using DataHandler to transfer files from a Java service to a non-Java
> > client? I've been digging around for months and any help would be
> > appreciated.
> >
> > Thanks.
> >
>
> --
> View this message in context:
> http://www.nabble.com/Using-DataHandler-for-attachments-tp22810928p22815936.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>