Hi All,

Thanks for the help (not).

After 2 days of sitting with this problem, I finally got it working.

I can now package a org.apache.axis.Message and manually send it over a
TCP/IP socket, without getting that damn ERROR:
java.io.IOException: No serializer found for class
za.co.eskom.nrs.xmlvend.Login_Response in registry
[EMAIL PROTECTED]

Here's how I did it:

//Create an EngineConfiguration using deploy.wsdd
InputStream is = getClass().getResourceAsStream("deploy.wsdd");
FileProvider provider = new FileProvider(is);
//Create an AxisEngine
axisServer = new AxisServer(provider);
//Obtain the TypeMappingRegistry from the EngineConfiguration
tmr = provider.getTypeMappingRegistry();

//Create the response
Login_Response loginResBean = new Login_Response();
loginResBean.setCurrentVendorCredit(new CurrencyT(new
BigDecimal(123.00)));
            
MessageContext msgContext0 = new MessageContext( axisServer );
// Set the TypeMappingRegistry in the MessageContext so that
// it will know how to Serialize the loginResBean
msgContext0.setTypeMappingRegistry(tmr);
msgContext0.setEncodingStyle("");
msgContext0.setUseSOAPAction(false);
            
QName operationName = new
javax.xml.namespace.QName("http://www.nrs.eskom.co.za/XMLVend/";,
"Login_RequestResponse");
RPCParam rpcParam = new
RPCParam("http://www.nrs.eskom.co.za/XMLVend/","Login_Response",loginResBean); 
RPCElement body = new RPCElement(operationName.getNamespaceURI(),
                                operationName.getLocalPart(), new Object
[] {rpcParam});
org.apache.axis.message.SOAPEnvelope resEnv = new
org.apache.axis.message.SOAPEnvelope(msgContext0.getSOAPConstants(),
msgContext0.getSchemaVersion());
org.apache.axis.Message resMsg = new org.apache.axis.Message( resEnv );
resEnv.addBodyElement(body);
resEnv.setMessageType(org.apache.axis.Message.RESPONSE);
resMsg.setMessageType(org.apache.axis.Message.RESPONSE);
// Don't forget to set the MessageContext for the 
// resMsg otherwise it won't get the TypeMappingRegistry
// which is need to Serialize the encapsulated loginResBean.
resMsg.setMessageContext(msgContext0);


I thank you.

Enrico  




On Thu, 2004-05-13 at 13:34, Enrico Goosen wrote:
> Hi All,
> 
> Found the attached email while searching the mailing list
> archives...which corresponds to the problem that I'm currently
> experiencing.
> 
> Don't think anyone replied to this email.
> 
> My previous email:
> 
> //First create an AxisServer using deploy.wsdd
> InputStream is = getClass().getResourceAsStream("deploy.wsdd");
> FileProvider provider = new FileProvider(is);
> axisServer = new AxisServer(provider);
> 
> ...
> 
> //Process response
> Login_Response loginResBean = new Login_Response();
> loginResBean.setCurrentVendorCredit(new CurrencyT(new
> BigDecimal(777.00)));
>             
> MessageContext msgContext0 = new MessageContext( axisServer );
>             
> QName operationName = new
> javax.xml.namespace.QName("http://www.nrs.eskom.co.za/XMLVend/";,
> "Login_Response");
> RPCParam rpcParam = new RPCParam(
> "http://www.nrs.eskom.co.za/XMLVend/";,                         
> "Login_RequestResponse",                                                        
> loginResBean); 
> RPCElement body = new RPCElement(
> operationName.getNamespaceURI(),
> operationName.getLocalPart(), 
> new Object [] {rpcParam});
> org.apache.axis.message.SOAPEnvelope reqEnv = new
> org.apache.axis.message.SOAPEnvelope(msgContext0.getSOAPConstants(),
> msgContext0.getSchemaVersion());
> org.apache.axis.Message reqMsg = new org.apache.axis.Message( reqEnv );
> reqEnv.addBodyElement(body);
> reqEnv.setMessageType(org.apache.axis.Message.RESPONSE);
>             
> return reqMsg;
> 
> Now I'm getting the following error:
> 
> java.io.IOException: No serializer found for class
> za.co.eskom.nrs.xmlvend.Login_Response in registry
> [EMAIL PROTECTED]
> 
> Any ideas?
> 
> Regards,
> Enrico
> 
> 
> 
> ----
> 

> Hi all,
> 
> I am creating my own EngineConfiguration implementation, in order to do all
> deployments programmatically (without wsdd file).
> 
> I have successfully deployed all my services. When I make a GET request from
> a browser to a service that only uses basic types,
> all works fine.
> 
> But when I try to call any service method that returns a bean, the request
> fails with an exception indicating that no appropriate serializer
> has been found for it.
> 
> I have registered all type mappings I need, but it seems that Axis is not
> using my EngineConfiguration to retrieve those mappings.
> 
> I added a "println" in my getTypeMappingRegistry method, and it is not shown
> on console, so I guess I have to do anything else to
> indicate Axis that it should use my EngineConfiguration to retrieve the
> mappings, but I have found nothing related to this in the documentation, nor
> the mail list archives.
> 
> Does anybody know why Axis is not using my EngineConfiguration to get the
> type mappings? How can I configure the engine to use them?
> 
> Following these lines I have put the source code of my implementation:
> 
> Thanks in advance,
> Rodrigo Ruiz Aguayo
> 
> ----------------------------------------------------------------------
> package my.package;
> 
> import javax.servlet.ServletContext;
> import javax.xml.namespace.QName;
> 
> import org.apache.axis.AxisEngine;
> import org.apache.axis.ConfigurationException;
> import org.apache.axis.Constants;
> import org.apache.axis.EngineConfiguration;
> import org.apache.axis.configuration.SimpleProvider;
> import org.apache.axis.encoding.DeserializerFactory;
> import org.apache.axis.encoding.SerializerFactory;
> import org.apache.axis.encoding.TypeMapping;
> import org.apache.axis.encoding.TypeMappingImpl;
> import org.apache.axis.encoding.TypeMappingRegistry;
> import org.apache.axis.encoding.TypeMappingRegistryImpl;
> import org.apache.axis.encoding.ser.BaseSerializerFactory;
> import org.apache.axis.encoding.ser.BeanDeserializerFactory;
> import org.apache.axis.encoding.ser.BeanSerializerFactory;
> import org.apache.axis.enum.Scope;
> import org.apache.axis.handlers.soap.SOAPService;
> import org.apache.axis.providers.java.RPCProvider;
> 
> /**
>  * We want our server to have some fixed services, and nothing
>  * more, so we should not use a wsdd file at all.
>  * By now, we need a default EngineConfiguration to do
>  * some configuration staff, and we are using a FileProvider, but
>  * as we do not use it after initialization, its deployments are ignored.
>  */
> public class ApiConfiguration extends SimpleProvider {
>   /**
>    * All API Services use this instance as the provider
>    */
>   private ApiProvider provider = new ApiProvider();
>   private EngineConfiguration defConfig = null;
>   private TypeMappingRegistry tmr = null;
>   private TypeMapping tm = null;
>   private AxisEngine engine = null;
> 
>   /**
>    * Creates a new instance
>    */
>   public ApiConfiguration(EngineConfiguration defConfig) {
>     super(defConfig);
>     this.defConfig = defConfig;
>   }
> 
>   public void configureEngine(AxisEngine engine) throws
> ConfigurationException {
>     super.configureEngine(engine);
>     this.engine = engine;
>     System.out.println("Engine configured!");
>   }
> 
>   /**
>    * Deploys all public APIs.
>    */
>   public void deployApiClasses(ServletContext ctx) {
>     String s = ctx.getInitParameter("with-informer");
>     boolean withInformer = ("true".equalsIgnoreCase(s));
>     ApiProvider.withInformer = withInformer;
>     ApiReflector[] apis = ApiReflector.getApiList(ctx);
>     for (int i = 0; i < apis.length; i++) {
>       if (withInformer || !apis[i].getApiName().equals("IgApiInformer")) {
>         deployApi(apis[i]);
>       }
>     }
>   }
> 
>   /**
>    * Deploys a single API specified by the passed reflector
>    */
>   private void deployApi(ApiReflector reflector) {
>     try {
>       SOAPService service = new SOAPService(provider);
>       Class apiClass = reflector.getApiClass();
>       String apiName = reflector.getApiName();
>       service.setName(apiName);
>       service.setOption( RPCProvider.OPTION_WSDL_SERVICEPORT, apiName );
>       service.setOption( RPCProvider.OPTION_SCOPE,
> Scope.APPLICATION.getName());
>       service.setOption( RPCProvider.OPTION_CLASSNAME,
> reflector.getApiClassName() );
>       service.setOption( RPCProvider.OPTION_ALLOWEDMETHODS,
> reflector.getAllowedMethods() );
>       deployService( apiName, service );
> 
>       // ApiMapper is a replacement for URLMapper, that knows how to handle
> requests from
>       // old clients that use ApacheSOAP and send SOAPAction:""
>       ApiMapper.addMap( "urn:" + apiName.toLowerCase(), apiName );
>       System.out.println("Deployed " + apiName);
>     }
>     catch (Exception e) {
>       System.out.println("Failed to deploy " + reflector.getApiName());
>       e.printStackTrace();
>     }
>   }
> 
>   /**
>    * Code extracted from WSDDDeployment
>    */
>   public void setTypeMappingRegistry(ServletContext ctx) {
>     try {
>       this.tmr = new TypeMappingRegistryImpl();
> 
>       // Gets / Creates the TypeMapping instance
>       String encodingStyle = Constants.URI_DEFAULT_SOAP_ENC;
>       tm = (TypeMapping) tmr.getTypeMapping(encodingStyle);
>       TypeMapping df = (TypeMapping) tmr.getDefaultTypeMapping();
>       if (tm == null || tm == df) {
>         tm = (TypeMapping) tmr.createTypeMapping();
>         tm.setSupportedEncodings(new String[] {encodingStyle});
>         tmr.register(encodingStyle, tm);
>       }
> 
>       ApiReflector beans[] = ApiReflector.getBeanList(ctx);
>       for (int i = 0; i < beans.length; i++) {
>         deployMapping(beans[i]);
>       }
>     }
>     catch (Exception e) {
>     }
>   }
> 
>   /**
>    * I do a "special mapping". All my beans are internal implementations
>    * of public interfaces, that are used as the service method parameters.
>    * As interfaces cannot be deserialized, I register a mapping for the
>    * interface, and another for the implementor class.
>    */
>   private void deployMapping(ApiReflector reflector) {
>     System.out.println("Registering type " + reflector.getApiName());
>     SerializerFactory isf = null;
>     DeserializerFactory bdf = null;
> 
>     QName qname = new QName(reflector.getApiName().toLowerCase());
>     isf = new BeanSerializerFactory(reflector.getApiInterface(), qname);
>     bdf = new BeanDeserializerFactory(reflector.getApiClass(), qname);
> 
>     tm.register( reflector.getApiInterface(), qname, isf, null );
>     tm.register( reflector.getApiClass(), qname, isf, bdf );
>   }
> 
>   /**
>    * I expect this method to be called by Axis to retrieve my type mappings
>    * but the log is not printed in console, so I guess Axis is using another
>    * mechanism to obtain the mappings.
>    */
>   public TypeMappingRegistry getTypeMappingRegistry() throws
> ConfigurationException {
>     System.out.println("Call to getTypeMappingRegistry!");
>     return tmr;
>   }
> }
> ----------------------------------------------------------------------


Reply via email to