国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > PHP > 正文

淺談PHP調用Webservice思路及源碼分享

2020-03-22 19:12:40
字體:
來源:轉載
供稿:網友
方法一:直接調用復制代碼 代碼如下:
?
/******************************************************************************/
/* 文件名 : soapclient.php
/* 說 明 : WebService接口客戶端例程
/******************************************************************************/
include('NuSoap.php');

// 創建一個soapclient對象,參數是server的WSDL
$client = new soapclient('http://localhost/Webservices/Service.asmx?WSDL', 'wsdl');

// 參數轉為數組形式傳遞
$aryPara = array('strUsername'= 'username', 'strPassword'= MD5('password'));

// 調用遠程函數
$aryResult = $client- call('login',$aryPara);

//echo $client- debug_str;
/*
if (!$err=$client- getError()) {
print_r($aryResult);
} else {
print "ERROR: $err";
}
*/

$document=$client- document;
echo SoapDocument
?xml version="1.0" encoding="GB2312"?
SOAP-ENV:Envelope SOAP-ENV:encoding xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd"
SOAP-ENV:Body
$document
/SOAP-ENV:Body
/SOAP-ENV:Envelope
SoapDocument;

?
復制代碼 代碼如下:
?
/******************************************************************************/
/* 文件名 : soapclient.php
/* 說 明 : WebService接口客戶端例程
/******************************************************************************/
include('NuSoap.php');// 創建一個soapclient對象,參數是server的WSDL
$client = new soapclient('http://localhost/Webservices/Service.asmx?WSDL', 'wsdl');// 參數轉為數組形式傳遞
$aryPara = array('strUsername'= 'username', 'strPassword'= MD5('password'));// 調用遠程函數
$aryResult = $client- call('login',$aryPara);//echo $client- debug_str;
/*
if (!$err=$client- getError()) {
print_r($aryResult);
} else {
print "ERROR: $err";
}
*/$document=$client- document;
echo SoapDocument
?xml version="1.0" encoding="GB2312"?
SOAP-ENV:Envelope SOAP-ENV:encoding xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd"
SOAP-ENV:Body
$document
/SOAP-ENV:Body
/SOAP-ENV:Envelope
SoapDocument;?
方法二:代理方式調用 復制代碼 代碼如下:
?
/******************************************************************************/
/* 文件名 : soapclient.php
/* 說 明 : WebService接口客戶端例程
/******************************************************************************/
require('NuSoap.php');

//創建一個soapclient對象,參數是server的WSDL
$client=new soapclient('http://localhost/Webservices/Service.asmx?WSDL', 'wsdl');

//生成proxy類
$proxy=$client- getProxy();

//調用遠程函數
$aryResult=$proxy- login('username',MD5('password'));

//echo $client- debug_str;
/*
if (!$err=$proxy- getError()) {
print_r($aryResult);
} else {
print "ERROR: $err";
}
*/

$document=$proxy- document;
echo SoapDocument
?xml version="1.0" encoding="GB2312"?
SOAP-ENV:Envelope SOAP-ENV:encoding xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd"
SOAP-ENV:Body
$document
/SOAP-ENV:Body
/SOAP-ENV:Envelope
SoapDocument;

?
復制代碼 代碼如下:
?
/******************************************************************************/
/* 文件名 : soapclient.php
/* 說 明 : WebService接口客戶端例程
/******************************************************************************/
require('NuSoap.php');//創建一個soapclient對象,參數是server的WSDL
$client=new soapclient('http://localhost/Webservices/Service.asmx?WSDL', 'wsdl');//生成proxy類
$proxy=$client- getProxy();//調用遠程函數
$aryResult=$proxy- login('username',MD5('password'));//echo $client- debug_str;
/*
if (!$err=$proxy- getError()) {
print_r($aryResult);
} else {
print "ERROR: $err";
}
*/$document=$proxy- document;
echo SoapDocument
?xml version="1.0" encoding="GB2312"?
SOAP-ENV:Envelope SOAP-ENV:encoding xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd"
SOAP-ENV:Body
$document
/SOAP-ENV:Body
/SOAP-ENV:Envelope

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 尼玛县| 昂仁县| 磐石市| 凤城市| 龙井市| 永泰县| 张家港市| 武汉市| 西安市| 泰顺县| 柯坪县| 大化| 屏东市| 五常市| 城固县| 渝北区| 资兴市| 兴国县| 五台县| 渝北区| 财经| 陆河县| 灵丘县| 丹棱县| 库伦旗| 罗定市| 沙河市| 宁乡县| 斗六市| 大石桥市| 宁德市| 汤原县| 大埔区| 眉山市| 奉化市| 禹城市| 江安县| 高要市| 大悟县| 盐亭县| 洛阳市|