java - HashMap 与 Camel cxf :component POJO dataFormat

标签 java web-services jax-ws cxf apache-camel

我的 WS 接口(interface):

@WebService
public interface WS{

    String decide(String word, MapWrapper parameters);

}

使用包装类:

public class MapWrapper {

    public HashMap<String, String> map;
}

from("cxf:http://localhost:8080/WS?serviceClass=ws.WS&dataFormat=POJO").to("stream:out"); //Just for testing purpose

使用 SOAPUI 调用时出现以下异常:

Error during type conversion from type: org.apache.cxf.message.MessageContentsList to the required type: byte[] with value [Test, ws.WS@1221bc6] due argument type mismatch

我认为 MapWrapper 类导致了这个异常。但如何解决这个问题呢?

最佳答案

同样的问题一遍又一遍......

请勿在作为 Web 服务公开的接口(interface)中使用 Java 特定的构造。我正在讨论HashMap

Web 服务是一种集成技术,旨在连接任何平台(甚至非 OO 客户端)中的组件。 Web服务中传递的所有对象都应该是值(value)传递对象。不是复杂的业务对象等。

这不仅是正确的方法,而且是编码和部署过程中问题最少的方法。

关于java - HashMap 与 Camel cxf :component POJO dataFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14914711/

相关文章:

java - 在java中设置字节值

Java:WeakReference.get() 在 System.gc() 之后返回不同

web-services - Orchard CMS 网络服务

java - 接口(interface) com.sun.xml.ws.developer.WSBindingProvider 在类加载器中不可见

java - 如何创建从 postgres 到 parquet 的管道?

java - 如何在 Eclipse 中有效地调试用 JNI 包装的 C 代码? (安卓开发)

java - Angular 调用 java web API 中 http.post 的参数传递

java将字符串转换为xml并解析节点

java - JAX-WS Soap 故障未出现在 WSDL 中

java - JAX-WS HashMap 和 .NET 字典的互操作性