postman 调用webservice
有个外部接口需要提供古老的webservice 格式接口。
1 设置格式

按照xml 格式设置。
2 消息体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报文 ]]>

3 client 调用
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 方式,外层不需要嵌套报文了,可以 直接调用。