简体   繁体   English

在客户端的Axis 1.2中自定义序列化JDK5枚举

[英]Custom serialization of JDK5 Enum in Axis 1.2 on client-side

I am migrating a SOAP web service to JDK1.5. 我正在将SOAP Web服务迁移到JDK1.5。 I have took advantage of native java enums in the new code. 我在新代码中利用了本地Java枚举。 For some reasons, I'm stuck with Axis 1.2 and it does not natively support JDK5 "enums". 由于某些原因,我坚持使用Axis 1.2,它本身不支持JDK5“枚举”。

I have found a tutorial on how to implement custom a serialization / deserialization for java enums: http://www.developpez.net/forums/d236564/java/developpement-web-java/web-services/utiliser-type-enum-jdk5-axis/ (in French). 我找到了有关如何为Java枚举实现自定义序列化/反序列化的教程: http : //www.developpez.net/forums/d236564/java/developpement-web-java/web-services/utiliser-type-enum- jdk5轴/ (法语)。

I have been able to successfully register those custom serialization handlers on the server side via the use of "typeMapping" elements in the ".wsdd" file. 通过使用“ .wsdd”文件中的“ typeMapping”元素,我已经能够在服务器端成功注册那些自定义序列化处理程序。

However, I can't figure out how to register the same classes on the client side, as I do not have a ".wssd" file here. 但是,我不知道如何在客户端上注册相同的类,因为这里没有“ .wssd”文件。

Any help would be appreciated. 任何帮助,将不胜感激。

Thanks, Raphael 谢谢,拉斐尔

I have finally found how to manually register a custom type mapping. 我终于找到了如何手动注册自定义类型映射。 I do it when creating an instance of a Service : 我在创建Service实例时这样做:

service = new Service(); 

// Get default type mapping
TypeMapping tmap = DefaultTypeMappingImpl.getSingletonDelegate();

// Register our custom serializer / deserializer 
tmap.register(
        MyCustomClass.class, 
        MyCustomClassQName, 
        new MyCustomSerizalizerFactory(), 
        new MyCustomDeserizalizerFactory());

// Add it back to the service
service.getTypeMappingRegistry().register(
        "http://schemas.xmlsoap.org/soap/encoding/", // Default encoding
        tmap);

I don't know whether it is the right way to do it, but it works ! 我不知道这是否是正确的方法,但是它有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM