赞
踩
有个外部接口需要提供古老的webservice 格式接口。
按照xml 格式设置。
不加envelope:
<soap:Envelope xmlns:soap="" target="_blank">http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:VersionMismatch</faultcode>
<faultstring>"urn:hl7-org:v3", the namespace on the "root" element, is not a valid SOAP version.</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
需要再正常报文外层嵌套envelope:
header 可忽略,body 下层嵌套具体方法,如:XX方法,参照wsdl
下面一层的 arg0,
<![CDATA[ xml报文 ]]>
- try {
- // 接口地址
- String address = "http://XXXXXX";
- // 代理工厂
- JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
- // 设置代理地址
- jaxWsProxyFactoryBean.setAddress(address);
- // 设置接口类型
- jaxWsProxyFactoryBean.setServiceClass(OrganizationInfoRegister.class);
- // 创建一个代理接口实现
- OrganizationInfoRegister organizationInfoRegister = (OrganizationInfoRegister) jaxWsProxyFactoryBean.create();
- // 数据准备
- String xml = "具体xml报文";
- // 调用代理接口的方法调用并返回结果
- String result = organizationInfoRegister.registerOrganizationInfo(xml);
- System.out.println("返回结果:" + result);
- } catch (Exception e) {
- e.printStackTrace();
- }

这种CxfClient 方式,外层不需要嵌套报文了,可以 直接调用。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。