从CXF生成的客户端访问Spring ws服务

CXF默认采用JAXB作为数据绑定方式, 从wsdl生成的客户端代码发送xml请求时,没有将xml命名空间写到soap head中,导致spring ws解析xml报错,需要在cxf客户端添加如下代码
                Client client = ClientProxy.getClient(port);
		client.getOutInterceptors();
		HashMap<String, String> hmap = new HashMap<String, String>();
		hmap.put("sch", "http://your/schemas");
		client.getRequestContext().put("soap.env.ns.map", hmap);
		client.getRequestContext().put("disable.outputstream.optimization", "true");

或者采用其他数据绑定方式

猜你喜欢

转载自zhoukai.iteye.com/blog/1650993