0

我的 WS 接口:

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

4

1 回答 1

1

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

不要在作为 Web 服务公开的接口使用Java特定结构。我正在考虑HashMap.

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

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

于 2013-02-16T20:24:58.637 回答