Hi
 
To fix this error you need to have something like
 
 
<typeMapping
> deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory
> "
> languageSpecificType="java:javax.activation.DataHandler"
> qname="ns1:DataHandler" xmlns:ns="somenamespace"
> serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory"
> encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/"
>      />
You are missing name space entry in you type mapping and that is why you are getting the error
Namespace prefixes must be set on the
Definition object using the addNamespace(...) method.:
Akhil
 
----- Original Message -----
From: "Jacek Gebala" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Toshiyuki Kimura" <[EMAIL PROTECTED]>
Sent: Thursday, July 03, 2003 11:21 AM
Subject: Re: help required for attachment using ejb as webservice

> Hi Toshi,
> Exactly!  I should use in wsdd file:
>
> deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory
> "
> serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory"
>
> instead of:
>
> deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
> serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
>
> After that, the example mentioned by me works.
> BUT!!! I cannot display the WSDL for this service from now on
>
> AXIS error
> Sorry, something seems to have gone wrong... here are the details:
>
> Fault - ; nested exception is:
> WSDLException: faultCode=OTHER_ERROR: Can&apos;t find prefix for
> &apos;http://activation.javax&apos;. Namespace prefixes must be set on the
> Definition object using the addNamespace(...) method.:
> AxisFault
>  faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
>  faultSubcode:
>  faultString: WSDLException: faultCode=OTHER_ERROR: Can&apos;t find prefix
> for &apos;http://activation.javax&apos;. Namespace prefixes must be set on
> the Definition object using the addNamespace(...) method.:
>  faultActor:
>  faultNode:
>  faultDetail:
> I also updated to AXIS 1.1 final and I tried to remove typeMapping from my
> wsdd. The example still works, but I still cannot get WSDL (the same error).
>
> Jacek.
>
>
> Hi Jacek,
>
>   Yes, you have a mistake about serializer's configuration.
> If you're using AXIS 1.1 final, please try again with no
> typeMapping on your wsdd.  (i.e. You should re-deploy your
> service, after you drop the typeMapping node on your wsdd.)
>
>   In case of any exceptions or using AXIS 1.1 earlier, please
> try to add the right typeMapping for DataHandler by referring
> to the following sample;
> .........*.........*.........*.........*.........*.........*.........*
> <deployment xmlns="
http://xml.apache.org/axis/wsdd/"
>  xmlns:java="
http://xml.apache.org/axis/wsdd/providers/java"
>  xmlns:ns1="urn:EchoAttachmentsService" >
>  <service name="urn:EchoAttachmentsService" provider="java:RPC" >
>   <parameter name="className"
>    value="samples.attachments.EchoAttachmentsService"/>
>   <parameter name="allowedMethods" value="echo echoDir"/>
>   <operation name="echo" returnQName="returnqname"
>    returnType="ns1:DataHandler" >
>    <parameter name="dh" type="ns1:DataHandler"/>
>   </operation>
>   <typeMapping
> deserializer="org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory
> "
> languageSpecificType="java:javax.activation.DataHandler"
> qname="ns1:DataHandler"
> serializer="org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory"
> encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/"
>      />
>   </service>
> </deployment>
> .........*.........*.........*.........*.........*.........*.........*
>
> Best Regards,
>
>    Toshi (Toshiyuki Kimura) <
[EMAIL PROTECTED]>
>    R&D Headquarters
>    NTT DATA Corporation
>
> -----Original Message-----
> From: Jacek Gebala [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, July 01, 2003 7:28 PM
> To:
[EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: help required for attachment using ejb as webservice
>
> Hi Toshi,
>
> Thank you for the explanation. It was very helpful to my understanding
> of the problem.
> My problem still is not solved. Your sugestion seems to be true. I guess,
> I have a problem with serializer's configuration.
> Could you give me some hints, please? What is needed to running correctly
> such simple example?
> Maybe my "server-config.wsdd" is wrong? I show you my very simple example.
> Anyway, When I used to write the similar method
> public DataHandler getAttachment();
> in normal Java class (NOT EJB) every thing went smoothly. I mean the example
> was working.
>
> //----Simple EJB------------------------------------------------------------
> package swa;
>
> import javax.activation.*;
> import javax.ejb.*;
>
> import org.apache.axis.*;
>
> public class DataProviderBean implements SessionBean {
>   SessionContext sessionContext;
>   public void ejbCreate() throws CreateException {
>    
/[EMAIL PROTECTED] Complete this method*/
>   }
>   public void ejbRemove() {
>    
/[EMAIL PROTECTED] Complete this method*/
>   }
>   public void ejbActivate() {
>    
/[EMAIL PROTECTED] Complete this method*/
>   }
>   public void ejbPassivate() {
>    
/[EMAIL PROTECTED] Complete this method*/
>   }
>   public void setSessionContext(SessionContext sessionContext) {
>     this.sessionContext = sessionContext;
>   }
>   public DataHandler getAttachment() {
>      String doc="Hello world.";
>
>   //The following two commented lines would force any attachments sent back.
>       //  to be in DIME format.
>       Message rspmsg =
>       AxisEngine.getCurrentMessageContext().getResponseMessage();
>       rspmsg.getAttachmentsImpl().setSendType(org.apache.axis.attachments.
>                                               Attachments.SEND_TYPE_DIME);
>
>       DataHandler dh = new DataHandler(doc, "text/plain");
>       return dh;
>   }
> }
> //----------------------------------------------------------------------
> //------WebService Client-----------------------------------------------
> package swa;
>
> import java.net.*;
> import javax.activation.*;
> import javax.xml.namespace.*;
>
> import org.apache.axis.*;
> import org.apache.axis.client.*;
> import org.apache.axis.encoding.ser.*;
> import org.apache.axis.utils.*;
>
> public class SwAClient {
>
>     public void getAttachment() throws Exception {
>
>        Service  service = new Service();
>        Call     call    = (Call) service.createCall();
>        call.setTargetEndpointAddress( new
>        URL(
http://localhost:7001/webservices/services/DataProvider?wsdl));
>        call.setOperationName(new QName("DataProvider","getAttachment") );
>        //This is the target services method to invoke.
>        QName qnameAttachment = new QName("DataProvider", "DataHandler");
>
> call.registerTypeMapping(Class.forName("javax.activation.DataHandler"),
> //Add serializer for attachment.
>                                 qnameAttachment,
>                                 JAFDataHandlerSerializerFactory.class,
>                                 JAFDataHandlerDeserializerFactory.class);
>        call.setReturnType( qnameAttachment);
>        call.setProperty(call.ATTACHMENT_ENCAPSULATION_FORMAT,
>                         call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME);
>        Object ret = call.invoke( new Object[] {
>                }
>            ); //Add the attachment.
>
>        if (null == ret) {
>            System.out.println("Received null ");
>            throw new AxisFault("", "Received null", null, null);
>        }
>
>        if (ret instanceof String) {
>        System.out.println("Received problem response from server: "+ret);
>            throw new AxisFault("", (String) ret, null, null);
>        }
>
>        if (!(ret instanceof DataHandler)) {
>          //The wrong type of object that what was expected.
>          System.out.println("Received problem response from server:" +
>              ret.getClass().getName());
>          throw new AxisFault("", "Received problem response from server:"
>          + ret.getClass().getName(), null, null);
>
>        }
>             DataHandler rdh = (DataHandler) ret;
>             System.out.println(rdh.getContentType());
>            System.out.println((String)rdh.getContent());
>    }
>
>     public static void main(String args[]) {
>         try {
>
>             Options opts = new Options(args);
>             SwAClient echoattachment = new SwAClient();
>             echoattachment.getAttachment();
>
>         }
>         catch ( Exception e ) {
>             if ( e instanceof AxisFault ) {
>                 ((AxisFault) e).dump();
>             }
>             System.err.println(e);
>              e.printStackTrace();
>         }
>         System.exit(18);
>     }
> }
>
> //-------------server-config.wsdd---------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <deployment xmlns="
http://xml.apache.org/axis/wsdd/"
> xmlns:java="
http://xml.apache.org/axis/wsdd/providers/java">
>  <globalConfiguration>
>   <parameter name="adminPassword" value="admin"/>
>   <parameter name="attachments.implementation"
> value="org.apache.axis.attachments.AttachmentsImpl"/>
>   <parameter name="sendXsiTypes" value="true"/>
>   <parameter name="sendMultiRefs" value="true"/>
>   <parameter name="sendXMLDeclaration" value="true"/>
>   <parameter name="axis.sendMinimizedElements" value="true"/>
>   <requestFlow>
>    <handler type="java:org.apache.axis.handlers.JWSHandler">
>     <parameter name="scope" value="session"/>
>    </handler>
>    <handler type="java:org.apache.axis.handlers.JWSHandler">
>     <parameter name="scope" value="request"/>
>     <parameter name="extension" value=".jwr"/>
>    </handler>
>   </requestFlow>
>  </globalConfiguration>
>  <handler name="LocalResponder"
> type="java:org.apache.axis.transport.local.LocalResponder"/>
>  <handler name="URLMapper"
> type="java:org.apache.axis.handlers.http.URLMapper"/>
>  <handler name="Authenticate"
> type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
>  <service name="DataProvider" provider="java:EJB">
>   <parameter name="allowedMethods" value="getAttachment"/>
>   <parameter name="beanJndiName" value="DataProvider"/>
>   <parameter name="homeInterfaceName" value="swa.DataProviderHome"/>
>   <typeMapping
> deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
> encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/"
> qname="ns1:DataHandler"
> serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
> type="java:javax.activation.DataHandler"
> xmlns:ns1="
http://activation.javax"/>
>  </service>
>  <service name="AdminService" provider="java:MSG">
>   <parameter name="allowedMethods" value="AdminService"/>
>   <parameter name="enableRemoteAdmin" value="false"/>
>   <parameter name="className" value="org.apache.axis.utils.Admin"/>
>   <namespace>http://xml.apache.org/axis/wsdd/</namespace>
>  </service>
>  <service name="Version" provider="java:RPC">
>   <parameter name="allowedMethods" value="getVersion"/>
>   <parameter name="className" value="org.apache.axis.Version"/>
>  </service>
>  <transport name="http">
>   <requestFlow>
>    <handler type="URLMapper"/>
>    <handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
>   </requestFlow>
>  </transport>
>  <transport name="local">
>   <responseFlow>
>    <handler type="LocalResponder"/>
>   </responseFlow>
>  </transport>
> </deployment>
>
> //---------------------------------------------------------------------
>
> Thanks in advance
> Jacek
> p.s. When I was working with webservices without attachments I didn't any
> problems with my WebLogic's configuration.
>
> > Hi Jacek,
> >
> >  A JAX-RPC implementation is required to support the following MIME
> > types to bind to various Java types according as JAX-RPC ver 1.0.
> > In other words, 'application/msword' is not required, basically.
> >
> >    MIME Type                  |  Java Type
> >  -----------------------------+-----------------------------------
> >   image/gif                   | java.awt.Image
> >   image/jpeg                  | java.awt.Image
> >   text/plain                  | java.lang.String
> >   multipart/*                 | javax.mail.internet.MimeMultipart
> >   text/xml or application/xml | javax.xml.transform.Source
> >
> >   So if you have any trouble with the DataHandler(obj, mimeType)
> > and a MIME type not specified above like as 'application/msword',
> > that meets the specification.
> >
> >   However, you have a chance to set other MIME types to your response
> > with a constructor 'DataHandler(DataSource ds)'.
> > And, please refer to the following site;
> >  <
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/activation/
> >   MimetypesFileTypeMap.html>
> >
> >   If you want to add new entries programmatically, see below;
> >     <snippet>
> >       String strMimeType = "application/msword doc";
> >       javax.activation.MimetypesFileTypeMap map =
> >                 new javax.activation.MimetypesFileTypeMap();
> >       map.addMimeTypes(strMimeType);
> >       javax.activation.FileTypeMap.setDefaultFileTypeMap( map );
> >     </snippet>
> >
> > P.S.
> >   It seems that you also have any other mistake on serializer
> > configuration. Check again.
> >
> > Best Regards,
> >
> >    Toshi (Toshiyuki Kimura) <
[EMAIL PROTECTED]>
> >    R&D Headquarters
> >    NTT DATA Corporation
> >
> > -----Original Message-----
> > From: Jacek Gebala [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, June 25, 2003 5:34 PM
> > To:
[EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED]
> > Subject: RE: help required for attachment using ejb as webservice
> >
> > Hi Toshi,
> >
> > Could you please to qualify how I can warp the byte of array to
> DataHandler?
> > When I write to:
> >
> > public DataHandler getAttachment() {
> >     DataHandler dataHandler = new
> > DataHandler(ArrayOfBytes,"application/msword");
> >     return dataHandler;
> >   }
> > The error is:
> > faultString: java.io.IOException: No serializer found for class
> > javax.activation.CommandInfo in registry
> >
[EMAIL PROTECTED]
> >
> > The question is:
> > Can I use DataHandler constructor (DataHandler(java.lang.Object obj,
> > java.lang.String mimeType) ) for passing on array of bytes? Type of
> content
> > is MS Word document (mimeType: application/msword).
> > Or should I use specific DataSource class (look at the example below)?
> > If yes, what the class should I use? I don't see any adequate in package
> > org.apache.axis.attachments.*;
> >
> > Anyway, when I try to write a example:
> >
> > public DataHandler getAttachment() {
> >     String doc="Hello world.";
> >     PlainTextDataSource textDS = new PlainTextDataSource("text",doc);
> >     DataHandler dataHandler = new DataHandler(textDS);
> >     return dataHandler;
> >   }
> >
> > The error is:
> > faultString: java.io.IOException: No serializer found for class
> > java.io.ByteArrayOutputStream in registry
> >
[EMAIL PROTECTED]
> >
> > What is wrong? I'm confused.
> > I use WebLogic 7 SP 1, and AXIS 1.1 RC1. I want to use MS SOAP Toolkit 3.0
> > on client machine.
> > Do you have any guidelines?
> >
> > Thanks in advance.
> >
> > Jacek Gebala
> > empolis Poland
> >
>
>

Reply via email to