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 ta...@mandic.com.br on 2003/07/02 22:46:33 UTC
HELP-ME!!!
I´m tryng to do a Stateless Session Bean as webservice with attachament.
The SessionBean have a method:
public DataHandler getFile();
My deploy is:
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="ArquivoTeller" provider="java:EJB">
<parameter name="allowedMethods" value="*"/>
<parameter name="beanJndiName"
value="java:com/casaevideo/pi/server/informacao/arquivo/ArquivoTellerLocal"/>
<parameter name="homeInterfaceName"
value="com.casaevideo.pi.server.ejb.informacao.arquivo.ArquivoTellerLocalHome"/>
<parameter name="remoteInterfaceName"
value="com.casaevideo.pi.server.ejb.informacao.arquivo.ArquivoTellerLocal"/>
</service>
</deployment>
All run fine... But i WSDL the type is
<wsdl:message name="getFileResponse">
<wsdl:part name="getFileReturn" type="apachesoap:DataHandler"/>
</wsdl:message>
Why? I want to user Attachaments. What I need to do. I tried to use as it, but when I
try to import wsdl to C# this type is not imported.
All other method run fine... The webservice without it is ok.
Please! Help-me!
Re: HELP-ME!!!
Posted by Akhil Gupta <ag...@eircom.net>.
Hi
I wrote a session bean that was deployed as web service and was sending the
content of file on invocation
of a method. To do that you don't have to use a DataHandler object. To my
understanding DataHandler
is just a wrapper object which can contain another object and some more
information for that object.
I am adding the code of my session bean I wrote to transmit the file. It is
quite simple and maybe it will
solve your problem:-
public byte[] echo(String fileName)
{
System.err.println("In echo");
byte[] retValue = new byte[0];
if(fileName==null)
{
System.err.println("FileName is null");
}
else
{
System.err.println("Recieved \""+fileName+"\".");
File file = new File(fileName);
int length = (int)(file.length());
FileInputStream fileiStream = null;
if(file.exists())
{
try
{
fileiStream = new FileInputStream(file);
retValue = new byte[length];
fileiStream.read(retValue);
}
catch(IOException ex)
{ ex.printStackTrace(); }
finally
{
try
{
fileiStream.close();
}
catch(IOException ex)
{ ex.printStackTrace();}
}
}
}
return retValue;
}
I have a public method called echo that just reads the file and transmits as
a byte[] to the client. With this as byte[]
is a XML data type you should be able to write a C# client with the WSDL of
above method.
Akhil
----- Original Message -----
From: <ta...@mandic.com.br>
To: <ax...@ws.apache.org>
Sent: Wednesday, July 02, 2003 9:46 PM
Subject: HELP-ME!!!
> I´m tryng to do a Stateless Session Bean as webservice with attachament.
>
> The SessionBean have a method:
> public DataHandler getFile();
>
> My deploy is:
> <deployment xmlns="http://xml.apache.org/axis/wsdd/"
> xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
> <service name="ArquivoTeller" provider="java:EJB">
> <parameter name="allowedMethods" value="*"/>
> <parameter name="beanJndiName"
>
value="java:com/casaevideo/pi/server/informacao/arquivo/ArquivoTellerLocal"/
>
> <parameter name="homeInterfaceName"
>
value="com.casaevideo.pi.server.ejb.informacao.arquivo.ArquivoTellerLocalHom
e"/>
> <parameter name="remoteInterfaceName"
>
value="com.casaevideo.pi.server.ejb.informacao.arquivo.ArquivoTellerLocal"/>
> </service>
> </deployment>
>
> All run fine... But i WSDL the type is
> <wsdl:message name="getFileResponse">
> <wsdl:part name="getFileReturn" type="apachesoap:DataHandler"/>
> </wsdl:message>
>
>
> Why? I want to user Attachaments. What I need to do. I tried to use as it,
but when I
> try to import wsdl to C# this type is not imported.
>
> All other method run fine... The webservice without it is ok.
>
>
> Please! Help-me!
>
>
>