繁体   English   中英

PHP xml SOAP和laravel

[英]PHP xml SOAP and laravel

我一直在尝试找出如何使用php / laravel发出肥皂请求。 但是从两天以来对互联网的所有研究中,我唯一能找到的就是旧的生锈php代码,这些代码使肥皂请求甚至都不起作用:

这是我正在尝试使其工作的一个片段,因此我对那些肥皂请求有一个大致的了解,但我只会收到无法建立soapclient的错误:

<?php


$aHTTP['http']['header'] =  "User-Agent: PHP-SOAP/5.5.11\r\n";

$aHTTP['http']['header'].= "username: XXXXXXXXXXX\r\n"."password: XXXXX\r\n";

$context = stream_context_create($aHTTP);

$client=new SoapClient("http://www.thomas-bayer.com/axis2/services/BLZService?wsdl",array('trace' => 1,"stream_context" => $context));

$result =  $client::__getFunctions();

var_dump($result);

因为看起来很难用php找到有关肥皂的任何信息?

这是我目前使用curl语句通过php向付款服务提供商提出的肥皂请求的示例。 基本上将您要发出的xml请求映射为一个字符串。 该字符串将在curl post字段中发送,并返回响应。

$soapdata="<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:tns='tns:ns'>
<soapenv:Header>
  <tns:CheckOutHeader>
    <MERCHANT_ID>$merchantid</MERCHANT_ID>
    <PASSWORD>$password</PASSWORD>
    <TIMESTAMP>$timestamp</TIMESTAMP>
  </tns:CheckOutHeader>
</soapenv:Header>
<soapenv:Body>
  <tns:processCheckOutRequest>
    <MERCHANT_TRANSACTION_ID>$merchanttransactionid</MERCHANT_TRANSACTION_ID>
    <REFERENCE_ID>$referenceid</REFERENCE_ID>
    <AMOUNT>$amount</AMOUNT>
    <MSISDN>$mobileno</MSISDN>
    <!--Optional:-->
    <ENC_PARAMS></ENC_PARAMS>
    <CALL_BACK_URL>$callbackurl</CALL_BACK_URL>
    <CALL_BACK_METHOD>$callbackmethod</CALL_BACK_METHOD>
    <TIMESTAMP>$timestamp</TIMESTAMP>
  </tns:processCheckOutRequest>
</soapenv:Body>
</soapenv:Envelope>";
//End Soap data
//We call the server for the first time
//end calling function
function makesoaprequest($url, $soapdata)
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml', 'Authorization: Basic'));
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "$soapdata");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    //Begin SSL
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    //End SSL
    $response = curl_exec($ch);
    return $response;
    curl_close($ch);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM