带有camel cxf的HashMap:组件POJO dataFormat

时间:2013-02-16 20:18:59

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

我的WS-Interface:

@WebService
public interface WS{

    String decide(String word, MapWrapper parameters);

}

使用WrapperClass:

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类导致了这个异常。但是如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

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

在您公开为Web服务的接口中使用Java个特定构造。我正在考虑HashMap

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

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