怎么禁止cxf对发送的soap字符串信息进行转码???
我用cxf调用xfire写的服务端,其中有一个方法uploadDatas(String uploadData),这个方法中的参数是要传到服务端的xml字符串信息,用cxf客户端调用xfire服务端代码如下
public static void main(String[] args) throws Exception{ String dataString = " <root>"+ " <rptDate>2012-03-12</rptDate>"+ " <report>aaaa</report>"+ " <datas>"+ " <data>"+ " <category>bbb</category>"+ " <data>1.3</data>"+ " </data>"+ " </datas>"+ " </root>"; JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); Map<String, String> outTransformMap = Collections.singletonMap("<", "<"); StaxTransformFeature staxTransformFeature = new StaxTransformFeature(); staxTransformFeature.setOutTransformElements(outTransformMap); List<AbstractFeature> staxTransformFeatureList = new ArrayList<AbstractFeature>(); staxTransformFeatureList.add(staxTransformFeature); factory.setFeatures(staxTransformFeatureList); factory.setAddress("http://aaaa/Data"); factory.setServiceClass(Data.class); Data service = (Data) factory.create(); String response = service.uploadDatas("xml", dataString); }
<bean id="transformFeature" class="org.apache.cxf.feature.StaxTransformFeature"> <property name="inAppendElements"> <map> <!-- replace the text content of {ns}a element with the 'new Text' value --> <entry key="{ns}a" value="{ns}a=new Text"/> </map </property></bean>
Map<String, String> outTransformMap = Collections.singletonMap("<", "<"); StaxTransformFeature staxTransformFeature = new StaxTransformFeature(); staxTransformFeature.setOutTransformElements(outTransformMap); List<AbstractFeature> staxTransformFeatureList = new ArrayList<AbstractFeature>(); staxTransformFeatureList.add(staxTransformFeature); factory.setFeatures(staxTransformFeatureList);