1 Reply Latest reply on Sep 19, 2002 3:59 PM by Emily

    specifying DataHandler as input argument for webservice

    Filip Defoort Newbie


      Has anyone been able to register a DataHandler
      as an input parameter to an Axis call (using
      Jbossj-3.1.0alpha_tomcat-4.0.4, which includes
      AxisB1) ?

      When I pass in the datahandler into the Call.invoke,
      I get following error (before even attempting to
      make the call..):

      java.lang.IllegalArgumentException: argument type mismatch on object "$Proxy88", method name "dummy", tried argument typ
      es: org.apache.axis.attachments.AttachmentPart
      at org.apache.axis.message.SOAPFaultBuilder.endElement(Unknown Source)
      at org.apache.axis.encoding.DeserializationContextImpl.endElement(Unknown Source)
      at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1528)
      at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
      at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
      at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
      at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
      at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
      at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
      at org.apache.axis.encoding.DeserializationContextImpl.parse(Unknown Source)
      at org.apache.axis.SOAPPart.getAsSOAPEnvelope(Unknown Source)
      at org.apache.axis.client.Call.invoke(Unknown Source)

      Here's a code snippet that shows what I'm doing
      (and hopefully also what I'm NOT doing!):


      call.registerTypeMapping( DataHandler.class,
      new QName("DataHandler"),
      JAFDataHandlerDeserializerFactory.class );

      // Call to addParameter/setReturnType as described in user-guide.html
      call.addParameter(new QName("handlerIn"),
      new QName("DataHandler"),

      call.setReturnType( new QName("DataHandler") );

      Object ret = null;
      try {
      logger.debug("calling dummy");
      ret = call.invoke( new Object[] { inputH } );

      } ..... ((inputH is a DataHandler that is passed in).

      Many thanks in advance!

      - Filip

        • 1. Re: specifying DataHandler as input argument for webservice
          Emily Newbie

          Here is my code that works and does pretty much the same thing, but I'm using axis b2...

          DataHandler dhSource = new DataHandler( new FileDataSource( filename ));

          Service service = new Service();
          Call call = (Call) service.createCall();
          logger.info("Invoking the service at " + serviceURL);
          call.setTargetEndpointAddress( new URL(serviceURL) ); //Set the target service host and service location
          call.setOperationName(new QName("urn:UploadManagerService","upload") ); //This is the target service method to invoke.
          QName qnameAttachment = new QName("urn:UploadManagerService", "DataHandler");

          call.registerTypeMapping(dhSource.getClass(),//Add serializer for attachment.

          result = (String)call.invoke( new Object[] { dhSource } ); //Add the attachment.