[英]How to send this SOAP request with PHP
I'm trying to integrate with a third party API and their API accpets only SOAP requests. 我正在尝试与第三方API集成,并且它们的API仅支持SOAP请求。 They have this sample in their documentation.
他们在文档中有此样本。 All I need is to replace the agentcode and mpin.
我所需要做的就是替换agentcode和mpin。 Pls I need some one to help me write a PHP code to send the below format to this link http://202.140.50.116/EstelServices/services/EstelServices?wsdl using SOAP request
请我帮我写一个PHP代码,以使用SOAP请求将以下格式发送到此链接http://202.140.50.116/EstelServices/services/EstelServices?wsdl
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="http://services.estel.com"
xmlns:bal="http://balance.support.services.estel.com">
<soapenv:Header/>
<soapenv:Body>
<ser:getBalance>
<ser:balanceRequest>
<bal:agentCode>TPR_CM</bal:agentCode>
<bal:mpin>EE17F932B3C311E8877F999DD7865E11</bal:mpin>
</ser:balanceRequest>
</ser:getBalance>
</soapenv:Body>
</soapenv:Envelope>
Heres what I have tried so far 到目前为止,我一直在尝试
$xml = '<?xml version="1.0" encoding="utf-8"?>'.
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.estel.com" xmlns:bal="http://balance.support.services.estel.com">'.
'<soapenv:Header/>'.
'<soapenv:Body>'.
'<ser:getBalance>'.
'<ser:balanceRequest>'.
'<bal:agentCode>TPR_CM</bal:agentCode>'.
'<bal:mpin>EE17F932B3C311E8877F999DD7865E11</bal:mpin>'.
'</ser:balanceRequest>'.
'</ser:getBalance>'.
'</soapenv:Body>'.
'</soapenv:Envelope>';
$url = "http://balance.support.services.estel.com";
$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);
var_dump($result);
Use this simple script, which gives you enough information. 使用此简单脚本,可以为您提供足够的信息。 Function and type lists will help you to make correct SOAP call:
函数和类型列表将帮助您进行正确的SOAP调用:
<?php
// SOAP
$soap = new SoapClient("http://202.140.50.116/EstelServices/services/EstelServices?wsdl");
// 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>';
}
?>
Use the PHP native SoapClient along with the service WSDL: 将PHP本机SoapClient与服务WSDL一起使用:
$atservices_wsdl = "http://202.140.50.116/EstelServices/services/EstelServices?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.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.