21,887
社区成员
发帖
与我相关
我的任务
分享
<?php
/*
* $Id: client1.php,v 1.3 2007/11/06 14:48:24 snichol Exp $
*
* Client sample that should get a fault response.
*
* Service: SOAP endpoint
* Payload: rpc/encoded
* Transport: http
* Authentication: none
*/
require_once('../lib/nusoap.php');
$client = new nusoap_client("http://service.48pt.com/Consumption/lasCharge.asmx");
$client->soap_defencoding = "UTF-8";
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
exit();
}
$client->setUseCurl($useCURL);
// This is an archaic parameter list
$params = array(
'PtAcc' => "sungfeng21",
'source' => 12,
'moneyType' => '1',
'merchantId' => '105',
'serverId' => '1201',
'serviceId' => '102',
'orderId' => '12345678912345678912345',
'curr' => 1,
'moneyAmount' => '1',
'amount' => '100',
'moneyList' => '100',
'pname' => '0',
'commodity' => '0',
'callTime' => '2009-09-11 09:33:25',
'userIP' => '127.0.0.1',
'serverIP' => '61.164.40.187'
);
$result = $client->call('UserAccountDealing', $params,'', '', false, true);
if ($client->fault) {
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; print_r($result); echo '</pre>';
} else {
$err = $client->getError();
if ($err) {
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>';
}
}
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
?>
$ok_url ="http://service.48pt.com/Consumption/lasCharge.asmx";
$client = new SoapClient("".$ok_url."?WSDL");
$result = $client->UserAccountDealing(array("myAI" => $r));
$su = $result -> UserAccountDealingResult;
$client = new SoapClient("http://service.48pt.com/Consumption/lasCharge.asmx?wsdl");
$params = array(
'PtAcc' => "sungfeng21",
'source' => 12,
'moneyType' => '1',
'merchantId' => '105',
'serverId' => '1201',
'serviceId' => '102',
'orderId' => '12345678912345678912345',
'curr' => 1,
'moneyAmount' => '1',
'amount' => '100',
'moneyList' => '100',
'pname' => '0',
'commodity' => '0',
'callTime' => '2009-09-11 09:33:25',
'userIP' => '127.0.0.1',
'serverIP' => '61.164.40.187'
);
$p = $client->__Call('UserAccountDealing',array('parameters'=>$params));//这里有些区别,要这么来调用。
print_r($p);
lasCharge
UserAccountDealing
Important: Account recharge (When the account does not exist, the Create Account).
测试
测试窗体只能用于来自本地计算机的请求。
SOAP 1.1
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /Consumption/lasCharge.asmx HTTP/1.1
Host: service.48pt.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "WebGame.Consumption/UserAccountDealing"
<?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>
<UserAccountDealing xmlns="WebGame.Consumption">
<myAI>
<PtAcc>string</PtAcc>
<source>int</source>
<moneyType>int</moneyType>
<merchantId>string</merchantId>
<serverId>string</serverId>
<serviceId>string</serviceId>
<orderId>string</orderId>
<curr>int</curr>
<moneyAmount>decimal</moneyAmount>
<amount>decimal</amount>
<moneyList>string</moneyList>
<pname>string</pname>
<commodity>string</commodity>
<callTime>string</callTime>
<userIP>string</userIP>
<serverIP>string</serverIP>
</myAI>
</UserAccountDealing>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?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>
<UserAccountDealingResponse xmlns="WebGame.Consumption">
<UserAccountDealingResult>int</UserAccountDealingResult>
</UserAccountDealingResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /Consumption/lasCharge.asmx HTTP/1.1
Host: service.48pt.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<UserAccountDealing xmlns="WebGame.Consumption">
<myAI>
<PtAcc>string</PtAcc>
<source>int</source>
<moneyType>int</moneyType>
<merchantId>string</merchantId>
<serverId>string</serverId>
<serviceId>string</serviceId>
<orderId>string</orderId>
<curr>int</curr>
<moneyAmount>decimal</moneyAmount>
<amount>decimal</amount>
<moneyList>string</moneyList>
<pname>string</pname>
<commodity>string</commodity>
<callTime>string</callTime>
<userIP>string</userIP>
<serverIP>string</serverIP>
</myAI>
</UserAccountDealing>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<UserAccountDealingResponse xmlns="WebGame.Consumption">
<UserAccountDealingResult>int</UserAccountDealingResult>
</UserAccountDealingResponse>
</soap12:Body>
</soap12:Envelope>