WebService客户端,实现的功能是接收数据,按格式解析数据,最后存入相应数据库。
需求:
同步设备信息接口
url:http://localhost:54059/Service1.asmx
函数名:GetDevConfigInfo
参数:无
返回值:string
返回值格式:
设备编号,设备名称,设备类型,设备IP,设备端口号,设备位置,安装时间;设备编号,设备名称,设备类型,设备IP,设备端口号,设备位置,安装时间;
思路分析:通过WSDL文件生成客户端Client,通过客户端Client得到数据流。Dao层实现对数据流的解析和把数据插入数据库的功能。Servive层调用Client和Dao实现把接收的数据解析存入数据库的功能。Controller层做了一个按钮触发,点击按钮执行Service。
导入WSDL文件
File---New---Other---Web Service Client
两种方式导入WSDL文件。如果有.wsdl源文件可以通过WSDL File选取源文件路径;或者选取WSDL URL。
点击Next----再点击Finish
WSDL文件
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="itarge-park" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="itarge-park" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementF