当前位置:   article > 正文

postman 调用webservice_postman调用webservice接口

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 调用

  1. try {
  2. // 接口地址
  3. String address = "http://XXXXXX";
  4. // 代理工厂
  5. JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
  6. // 设置代理地址
  7. jaxWsProxyFactoryBean.setAddress(address);
  8. // 设置接口类型
  9. jaxWsProxyFactoryBean.setServiceClass(OrganizationInfoRegister.class);
  10. // 创建一个代理接口实现
  11. OrganizationInfoRegister organizationInfoRegister = (OrganizationInfoRegister) jaxWsProxyFactoryBean.create();
  12. // 数据准备
  13. String xml = "具体xml报文";
  14. // 调用代理接口的方法调用并返回结果
  15. String result = organizationInfoRegister.registerOrganizationInfo(xml);
  16. System.out.println("返回结果:" + result);
  17. } catch (Exception e) {
  18. e.printStackTrace();
  19. }

这种CxfClient 方式,外层不需要嵌套报文了,可以 直接调用。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/702114
推荐阅读
  

闽ICP备14008679号