On Tue, May 6, 2008 at 11:08 PM, Simon Nash <[EMAIL PROTECTED]> wrote:

> Eugeny N Dzhurinsky wrote:
>
> > Hello there!
> >
> > I noticed there's no way to define a service which accepts an
> > InputStream and
> > returns an InputStream as a result (in fact it is possible to start such
> > service, but when a client calls the service - the XML error "Content is
> > not
> > allowed in prolog" raises somewhere inside transformer:
> >
> > org.apache.tuscany.sca.databinding.TransformationException:
> > org.apache.tuscany.sca.databinding.TransformationException:
> > javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
> > Content is not allowed in prolog.
> >        at
> > org.apache.tuscany.sca.databinding.xml.InputStream2Node.transform(InputStream2Node.java:48)
> >        at
> > org.apache.tuscany.sca.databinding.xml.InputStream2Node.transform(InputStream2Node.java:37)
> >        at
> > org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer.transform(DefaultTransformerExtensionPoint.java:199)
> >        at
> > org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:73)
> >        at
> > org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:148)
> >        at
> > org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:43)
> >        at
> > org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:73)
> >        at
> > org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.transform(DataTransformationInterceptor.java:186)
> >        at
> > org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:76)
> >        at
> > org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:286)
> >        at
> > org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:154)
> >        at $Proxy8.handleImage(Unknown Source)
> > )
> >
> > As a workaround I am passing and returning the arrays of bytes, however
> > I
> > don't really like such approach. And I hope there's some way to provide
> > custom
> > data binding for InputStream objects (stating them just a byte streams -
> > not a
> > complex objects).
> >
> > I am using WS-bindings, if that matters, and tuscany 1.2.
> >
> > Could somebody please advice? May be using web services isn't a good
> > idea to
> > pass and return a large BLOB for the service (image transformation in my
> > case)?
> >
> >  If this is going over Web services, the contents of the stream
> would need to be transmitted on the wire as an array of bytes.
> An InputStream can't be passed over Web services in its Java object
> form.  Do you want to pass an InputStream in this case so that you
> can avoid copying the same data multiple times during marshalling?
> If so, it should be possible to write a custom data binding that
> only does a single copy.
>
> For a local (intra-JVM) invocation using the default binding, it
> would be possible to write a custom data binding to pass an
> InputStream as a Java object.  Is this relevant to your application
> requirement?
>
>  Simon
>
>
I agree with what Simon said but from your comment at the end ("a large
BLOB") i wonder if what you need is an enhancement to our WS binding MTOM
support so that it works with binary data from an InputStream, if you are
using web service calls then MTOM [1] is the recommended way to pass around
binary data. That does work today in Tuscany but its probably not to hard to
get this implemented for you if it is what you need.

   ...ant

[1] http://ws.apache.org/axis2/1_0/mtom-guide.html

Reply via email to