duandan4680 2018-08-15 14:31
浏览 53

集成OneCard系统(soap xml curl)

I'm trying to integrate the system Point of Sale (POS) OneCard.net on my site. Example from the documentation:

Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="https://www.onecard.net/webservice">
<soapenv:Header/>
<soapenv:Body>
<web:POSCheckBalanceRequest>
<web:posUsername>test_pos</web:posUsername>
<web:signature>6cc1ca29793526f0d920e17a0d815afd</web:signature>
</web:POSCheckBalanceRequest>
</soapenv:Body>
</soapenv:Envelope>

I wrapped this up in Curl:

$posUsername='posUsername';
$secretKey='secretKey';
$signature=md5($posUsername.$secretKey);

$query='<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="https://www.onecard.net/webservice">
<soapenv:Header/>
<soapenv:Body>
<web:POSCheckBalanceRequest>
<web:posUsername>'.$posUsername.'</web:posUsername>
<web:signature>'.$signature.'</web:signature>
</web:POSCheckBalanceRequest>
</soapenv:Body>
</soapenv:Envelope>';


$url='https://www.onecard.net/webservice';
$channel = curl_init();
$options = [
    CURLOPT_URL => $url,
    CURLOPT_NOBODY => 0,
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_SSL_VERIFYPEER => 0,
    CURLOPT_SSL_VERIFYHOST => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_AUTOREFERER => true,
    CURLOPT_MAXREDIRS => 3,
    CURLOPT_TIMEOUT => 200,
    CURLOPT_CONNECTTIMEOUT => 150,
    CURLINFO_HEADER_OUT => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $query,
];
curl_setopt_array($channel, $options);
$content = curl_exec($channel);
curl_close($channel);
var_dump($content);

But I do not get any result. Help please who worked with this system.

I tried use Soap Client:

header("Content-Type: text/html; charset=utf-8");
header('Cache-Control: no-store, no-cache');
header('Expires: '.date('r'));
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_NOTICE);

class Message{
    public $posUsername;
    public $signature;
}

class POSCheckBalanceRequest{
    public $posUsername;
    public $signature;
}

class Request{
    public $POSCheckBalanceRequest;
}

$req = new Request();
$req->POSCheckBalanceRequest=new POSCheckBalanceRequest();
$req->POSCheckBalanceRequest->posUsername = 'posUsername';
$req->POSCheckBalanceRequest->signature = 'signature';


$client = new SoapClient("https://www.onecard.net/webservice",
    array( 'soap_version' => SOAP_1_2));

var_dump($client->__soapCall('POSCheckBalanceRequest', array('posUsername' => $req->POSCheckBalanceRequest->posUsername,'signature'=>$req->POSCheckBalanceRequest->signature)));

ERR_CONNECTION_RESET

But I do not get any result again. I tried in many ways, none yielded the result.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题