axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "reddy, ramachandra" <ramachandra.re...@anacomp.com>
Subject Axis2 Webservices error : Caused by: java.lang.InstantiationException: java.io.FileInputStream
Date Wed, 23 Jan 2008 15:35:51 GMT
Hi All,
I am a newbie to webservices. I have a webservice that I am implementing
. I need to send 
XMLString and and a file stream.
 
I tried this version where I sent xmlstring annd filestream as
OMElements it worked.
public OMElement service(OMElement element) throws AxisFault
{
//Get XML Request
OMText genericRequestXMLText =
(OMText)element.getFirstElement().getFirstOMChild();
String genericRequestXML = genericRequestXMLText.getText();
//Get input stream
OMText binaryNode =
(OMText)((OMElementImpl)element.getFirstElement().getNextOMSibling()).ge
tFirstOMChild();
DataHandler actualDH = (DataHandler) binaryNode.getDataHandler();
actualDH.getInputStream(); 
 ///Do my processing 
  //This works fine.
}

 
Now I want to expose on more method with DTO being passed like this
public SAILTransferObject pojoService(SAILTransferObject request )
throws AxisFault

{

        String xmlPayload =  request.getXMLMessage();

     InputStream ipStream =  request.getDocStream();

         // Rest of processing 

 

 

    //Response to be sent 

     SAILTransferObject  response  =  new SAILTransferObject ();

      ///populate response.......

    return response;

}

//Here is DTO description 

public class SAILTransferObject implements ISAILObject {

 private String xmlMessage = null;
 private InputStream docStream = null;
 public InputStream getDocStream() {
  return this.docStream;
 }
 public String getXMLMessage() {
  return this.xmlMessage;
 }
 public void setXMLMessage(String xmlMessage) {
  this.xmlMessage = xmlMessage;
 }
 public void setDocStream(InputStream docStream) {
  this.docStream = docStream;
 }
 public SAILTransferObject() {
  super();
 }
}

//My interface.
Interface ISAILObject extends Serializable{
    public String getXMLMessage() ;
   public InputStream getDocStream() ;
}
 
//SERVICE.XML
<service name="SAILWebService" scope="application">
    <description>
        SAIL WEB SERVICE
    </description>
 
 <!-- -->
 <operation name="service">
        <messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
  <parameter name="enableMTOM" locked="false">true</parameter>
    </operation>
 
 <operation name="pojoService">
    <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
        class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    <parameter name="enableMTOM" locked="false">true</parameter>
    </operation>
 
    <parameter name="ServiceClass">
    com.company.sail.webservices.SAILWebService</parameter>
</service>

//My client Program 
public static  void  callPojoBasedSAILService() throws Exception{
  System.out.println(":: callPojoBasedSAILService");
  
  RPCServiceClient serviceClient = new RPCServiceClient();
  Options options = serviceClient.getOptions();
  options.setTo(targetEPR);
  options.setProperty(Constants.Configuration.ENABLE_MTOM,
Constants.VALUE_TRUE);
  QName method = new QName("http://webservices.sail.docharbor.com",
"pojoService");
  DataHandler dataHandler = new DataHandler(new
FileDataSource("C:\\Resume.doc"));
  ISAILObject sailTransferDto = new SAILTransferObject("<test>This will
be a xml String</test>",dataHandler.getInputStream());
  Object[] inputArgs = new Object[] { sailTransferDto }; 
        //Class[] returnTypes = new Class[] { SAILTransferObject.class
};
        Class<?>[] returnTypes = new Class[] { SAILTransferObject.class
};
        try{
         Object[] response = serviceClient.invokeBlocking(method,
inputArgs, returnTypes);
         ISAILObject result = (ISAILObject) response[0];
         
   if(result== null){
    System.out.println("Result was nulll");
   }
   else{
    System.out.println("result :" + result.getXMLMessage());
    System.out.println("result :" + result.getDocStream());
   } 
        }
        catch(AxisFault e){
         System.out.println(""+e.toString());
         System.out.println("\n FaultAction:"+e.getFaultAction());
         System.out.println("\n Node:"+e.getFaultNode());
         System.out.println("\n Reason:"+e.getReason());
        }
 }

 
ERROR  Message :
[ERROR] Exception occurred while trying to invoke service method
pojoService
org.apache.axis2.AxisFault: java.io.FileInputStream
 at org.apache.axis2.AxisFault.makeFault(AxisFault.java:417)
 at
org.apache.axis2.engine.DefaultObjectSupplier.getObject(DefaultObjectSup
plier.java:29)
 at
org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:34
5)
 at
org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:38
5)
 at
org.apache.axis2.databinding.utils.BeanUtil.processObject(BeanUtil.java:
655)
 at
org.apache.axis2.databinding.utils.BeanUtil.ProcessElement(BeanUtil.java
:603)
 at
org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:53
5)
 at
org.apache.axis2.rpc.receivers.RPCUtil.processRequest(RPCUtil.java:153)
 at
org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:1
88)
 at
org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RP
CMessageReceiver.java:98)
 at
org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLo
gic(AbstractInOutMessageReceiver.java:40)
 at
org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessa
geReceiver.java:96)
 at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
 at
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostReques
t(HTTPTransportUtils.java:275)
 at
org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
 at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:237)
 at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:157)
 at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:214)
 at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:104)
 at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
20)
 at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardCon
textValve.java:198)
 at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:152)
 at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:104)
 at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
20)
 at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:137)
 at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:104)
 at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:117)
 at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:102)
 at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
20)
 at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:109)
 at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:104)
 at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:535
)
 at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:102)
 at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
20)
 at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
 at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
 at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:79
0)
 at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC
onnection(Http11Protocol.java:709)
 at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:57
2)
 at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:644)
 at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.InstantiationException: java.io.FileInputStream
 at java.lang.Class.newInstance0(Class.java:340)
 at java.lang.Class.newInstance(Class.java:308)
 at
org.apache.axis2.engine.DefaultObjectSupplier.getObject(DefaultObjectSup
plier.java:27)
 ... 41 more

 
 
If anyone has faced similar problem and have workaround please let me
know.Thanks in advance.
 
Thanks
Ramachandra
 

Mime
View raw message