客户端 Axis 1.2 中 JDK5 Enum 的自定义序列化

发布于 2024-09-27 02:22:52 字数 548 浏览 8 评论 0原文

我正在将 SOAP Web 服务迁移到 JDK1.5。 我在新代码中利用了本机 java 枚举。 由于某些原因,我一直使用 Axis 1.2,而且它本身并不支持 JDK5“枚举”。

我找到了一个关于如何为 java 枚举实现自定义序列化/反序列化的教程: http: //www.developpez.net/forums/d236564/java/developpement-web-java/web-services/utiliser-type-enum-jdk5-axis/(法语)。

我已经能够通过使用“.wsdd”文件中的“typeMapping”元素在服务器端成功注册这些自定义序列化处理程序。

但是,我不知道如何在客户端注册相同的类,因为我这里没有“.wssd”文件。

任何帮助将不胜感激。

谢谢, 拉斐尔

I am migrating a SOAP web service to JDK1.5.
I have took advantage of native java enums in the new code.
For some reasons, I'm stuck with Axis 1.2 and it does not natively support JDK5 "enums".

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).

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.

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.

Any help would be appreciated.

Thanks,
Raphael

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沧笙踏歌 2024-10-04 02:22:52

我终于找到了如何手动注册自定义类型映射。
我在创建 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 have finally found how to manually register a custom type mapping.
I do it when creating an instance of a 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 !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文