java webService介面如何傳參和接收引數
一、獲取介面資訊:
使用工具soapUI獲取介面呼叫資訊:
雙擊request:
複製介面呼叫格式:
webService介面通常傳遞xml引數因此需要組裝資料:
①若傳遞單個引數則:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cen="http://center.jiuzhou.com/">
<soapenv:Header/>
<soapenv:Body>
<cen:方法名>
<!--Optional:-->
<引數1>引數值</引數1>
<引數2>引數value</引數2>
</cen:方法名>
</soapenv:Body>
</soapenv:Envelope>
②若傳遞引數最終需要解析成一個物件則:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cen="http://center.jiuzhou.com/">
<soapenv:Header/>
<soapenv:Body>
<cen:方法名>
<![CDATA[ <!--這裡使用CDATA將引數xml包起來,從而不將引數解析成xml格式。
<!--Optional:-->
<屬性>引數值</屬性>
........
</cen:方法名>
]]>
</soapenv:Body>
</soapenv:Envelope>
二、獲取介面呼叫返回值:
webService介面返回值示例:
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body><ns2:getValueResponse xmlns:ns2="http://com.webserver/">
<addResult>xxxxxx</addResult>
</ns2:getValueResponse>
</S:Body>
</S:Envelope>
解析該返回值,addResult中的內容就是返回值