我要实现充值,接口http://service.48pt.com/Consumption/lasCharge.asmx
webservice
我要用PHP实现,
提交参数列表,在以下代码中,请高手帮忙<?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>';
?>
帮忙写一下,怎么实现让接口返回数据呢,,,
我哪里方法错误了,谢谢各位
webservice
我要用PHP实现,
提交参数列表,在以下代码中,请高手帮忙<?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>';
?>
帮忙写一下,怎么实现让接口返回数据呢,,,
我哪里方法错误了,谢谢各位
改成以下试试
-->
$client = new nusoap_client("http://service.48pt.com/Consumption/lasCharge.asmx?wsdl");我这边直接浏览http://service.48pt.com/Consumption/lasCharge.asmx发现ip未授权,没权限访问,不能帮你测试。
提供的操作列表
现在POST数据能过去,但是返回值错误,不知道是POST数据有问题还是什么 lasChargeUserAccountDealing
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>
不过最好还是用soapclient吧,php5自带有一个SoapClient.
不知道你用nusoap,提示什么错误没有呢?如果调用函数没错误,返回post过去的参数列表,估计就是你post过去的参数有问题了。
$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);
foolbirdflyfirst 这二天的帮忙
$client = new SoapClient("".$ok_url."?WSDL");
$result = $client->UserAccountDealing(array("myAI" => $r));
$su = $result -> UserAccountDealingResult;
解决代码,顺便贴2个 根据IP地址判断城市天气预报的代码
http://blog.studclub.cn/post/236.html