Webserver常用接口鏈接: https://blog.csdn.net/ermao_zbp/article/details/78542290
本文示例中的接口鏈接: http://www.webxml.com.cn/WebServices/WeatherWebService.asmx
以SOAP 1.1 爲例
1)webserver請求body
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<!--getWeatherbyCityName:是接口的名稱 -->
<getWeatherbyCityName xmlns="http://WebXml.com.cn/">
<!-- 此處填寫接口的參數 -->
<theCityName>string</theCityName>
</getWeatherbyCityName>
</soap:Body>
</soap:Envelope>
2)webserver響應的body結構
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getWeatherbyCityNameResponse xmlns="http://WebXml.com.cn/">
<!-- getWeatherbyCityNameResult:是方法的返回值 -->
<getWeatherbyCityNameResult>
<string>string</string>
<string>string</string>
</getWeatherbyCityNameResult>
</getWeatherbyCityNameResponse>
</soap:Body>
</soap:Envelope>
一、添加URL
以POST方式爲例,填寫webserver的請求地址,請求方式選擇‘POST’
二、設置Header
在header處添加:Content-Type:text/xml;charset=utf-8,utf-8是指定編碼格式,防止中文亂碼
三、 設置body
在body處填寫請求的實例,選擇row方式進行請求,並且選擇‘XML(text/xml)’
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<!--getWeatherbyCityName:是接口的名稱 -->
<!--接口功能: 獲取城市天氣情況 -->
<getWeatherbyCityName xmlns="http://WebXml.com.cn/">
<!--theCityName:表示的是接口的參數,此處填寫接口請求需要的全部參數 -->
<theCityName>北京</theCityName>
</getWeatherbyCityName>
</soap:Body>
</soap:Envelope>
四、發送請求
完成以上設置後,點擊‘Send’發送請求,並檢查接口的返回值