java - SOAP:如何在 Java 中调用 CountryInfoService WSDL 文件,例如使用 CapitalCity SOAP 操作
问题描述
您好,我设法使用带有“ wsimport ”命令的 Java-WS 生成 WSDL Java 类。WSDL 文件来自:
http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?wsdl
问题是我不熟悉如何使用它。如何对 CapitalCity SOAP 方法进行 SOAP 调用。
在 SOAPUI 中,您只需传递 CountryISOCode,如下所示:
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.oorsprong.org/websamples.countryinfo">
<soapenv:Header/>
<soapenv:Body>
<web:CapitalCity>
<web:sCountryISOCode>UKR</web:sCountryISOCode>
</web:CapitalCity>
</soapenv:Body>
</soapenv:Envelope>
如何在 Java 中做到这一点?这是我开始的代码。
CountryInfoService countryInfoService = new CountryInfoService();
我不知道接下来会发生什么。我再次尝试使用“ CapitalCity ”SOAP 操作。
解决方案
这是一个示例答案:
CountryInfoService countryInfoService = new CountryInfoService();
CountryInfoServiceSoapType countryInfoServiceSoapType = countryInfoService.getCountryInfoServiceSoap();
System.out.println(countryInfoServiceSoapType.capitalCity("RUS"));
//output is 'Moscow'
这就是如何使用它。
推荐阅读
- node.js - 无法在节点服务器上发布数据
- javascript - 如何使用javascript触发在javascript上创建的按钮?
- woocommerce - 如何检查woocommerce中是否存在订单号?
- haskell - 为什么在我的原始类型定义中没有定义类型类约束时添加了它?
- docker - 如何从命令行重置 docker-for-mac v2.1.0.0 kubernetes?
- matlab - 在 Matlab 中实现抽象属性的问题
- google-api - 我正在尝试解决我的 api 无法正常工作的原因
- python - asyncio run_until_complete 在 future 设置结果后阻塞(高速公路 websockets 和线程)
- r - 循环更改为矩阵然后运行测试
- python - 如果用户输入为空,如何结束类中的方法