生活随笔
收集整理的這篇文章主要介紹了
soap方式的远程调用示例代码
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
需要jar包根據(jù)import的內(nèi)容查看.
axis是升級版
package
com.soapimport java
.net.URLimport javax
.xml.namespace.QName
import javax
.xml.rpc.ParameterModeimport org
.apache.axis.client.Call
import org
.apache.axis.client.Service
import org
.apache.axis.encoding.XMLType
public class SoapAxisTest{public static void main(String[] args) {// 命名空間String nameSpace =
"http://zjgwyjx.org/"// 訪問方法String methodName =
"LoadData"// 服務(wù)地址String url =
"http://218.90.170.6:13567/Service1.asmx"String actionUrl = nameSpace + methodNameObject returnObj = nulltry {Service service = new Service()
Call call = null
call = (
Call) service
.createCall()QName qName = new QName(nameSpace, methodName)
call.setOperationName(qName)
call.setSOAPActionURI(actionUrl)// 接口方法的參數(shù)名, 參數(shù)類型,參數(shù)模式
IN(輸入),
OUT(輸出)
or INOUT(輸入輸出)
call.addParameter(new QName(nameSpace,
"DID"), XMLType
.XSD_STRING, ParameterMode
.IN)
call.addParameter(new QName(nameSpace,
"SDate"), XMLType
.XSD_STRING, ParameterMode
.IN)
call.addParameter(new QName(nameSpace,
"EDate"), XMLType
.XSD_STRING, ParameterMode
.IN)// 對應(yīng)參數(shù)Object[] paramValues = new Object[] {
"10301",
"2017-08-01 00:00:00",
"2017-08-01 23:59:59" }
call.setTimeout(
6000)
call.setReturnType(XMLType
.XSD_STRING)
call.setTargetEndpointAddress(new URL(url))returnObj =
call.invoke(paramValues)System
.out.println(returnObj)} catch (Exception ie) {ie
.printStackTrace()} }
}
總結(jié)
以上是生活随笔為你收集整理的soap方式的远程调用示例代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。