2018-12-21 07:51
浏览 206


I'm trying to integrate with a third party API and their API accpets only SOAP requests. They have this sample in their documentation. All I need is to replace the agentcode and mpin. Pls I need some one to help me write a PHP code to send the below format to this link using SOAP request


Heres what I have tried so far

        $xml = '<?xml version="1.0" encoding="utf-8"?>'.
            '<soapenv:Envelope xmlns:soapenv="" xmlns:ser="" xmlns:bal="">'.

    $url = "";

    $soap_do = curl_init();
    curl_setopt($soap_do, CURLOPT_URL,            $url );
    curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
    curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($soap_do, CURLOPT_POST,           true );
    curl_setopt($soap_do, CURLOPT_POSTFIELDS,    $xml);

    $result = curl_exec($soap_do);
    $err = curl_error($soap_do);
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dpsq8476 2018-12-21 08:34

    Use this simple script, which gives you enough information. Function and type lists will help you to make correct SOAP call:

    // SOAP
    $soap = new SoapClient("");
    // List functions
    echo 'Functions: '.'</br>';
    $functions = $soap->__getFunctions();
    foreach($functions as $item) {
        echo $item.'</br>';
    echo '</br>';
    // List types
    echo 'Types: '.'</br>';
    $types = $soap->__getTypes();
    foreach($types as $item) {
        echo $item.'</br>';
    echo '</br>';
    // Consume SOAP
    $params = array(
        "balanceRequest" => array(
            "agentCode" => "TPR_CM",
            "mpin" => "EE17F932B3C311E8877F999DD7865E11"
    // Consume SOAP
    $responce = $soap->getBalance($params);
    foreach($responce->getBalanceReturn as $name => $value) {
       echo $name.': '.$value.'<br>';
    打赏 评论
  • dqwh1219 2018-12-21 08:25

    Use the PHP native SoapClient along with the service WSDL:

    $atservices_wsdl = "";
    $atservices_client = new SoapClient($atservices_wsdl);
    $balance = $atservices_client->getBalance("TPR_CM","EE17F932B3C311E8877F999DD7865E11");
    print_r($balance); // review the returned object converted from SOAP response.
    打赏 评论

相关推荐 更多相似问题