2016-11-25 149 views
1
$method ='MerchantFinancialOperationWS'; 


    $configs = array(
     'soap_version' => SOAP_1_2, 
     'cache_wsdl' => WSDL_CACHE_NONE, 
     'exceptions' => false, 
     'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 
     'local_cert' => $cert_file, 
     'passphrase' => $cert_password 
    ); 
    if($debug) $configs['trace'] = true; 

    if(substr($url, -5) != '?WSDL') $url.= '?WSDL'; 
    $webService = new SoapClient($url, $configs); 

$data = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fin="http://financial.services.merchant.channelmanagermsp.sibs/"> 
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"> 
     <wsa:Action>http://financial.services.merchant.channelmanagermsp.sibs/MerchantFinancialOperationWS/requestFinancialOperationRequest</wsa:Action> 
     <wsa:ReplyTo> 
      <wsa:Address>https://enderecodeteste.pt</wsa:Address> 
     </wsa:ReplyTo> 
    </soapenv:Header> 
    <soapenv:Body> 
     <fin:requestFinancialOperation> 
      <arg0> 
       <messageType>N0003</messageType> 
       <aditionalData>TESTE</aditionalData> 
       <alias> 
        <aliasName>351#994999999</aliasName> 
        <aliasTypeCde>001</aliasTypeCde> 
       </alias> 
       <financialOperation> 
        <amount>400</amount> 
        <currencyCode>9782</currencyCode> 
        <operationTypeCode>022</operationTypeCode> 
        <merchantOprId>11111</merchantOprId> 
       </financialOperation> 
       <merchant> 
        <iPAddress>255.255.255.255</iPAddress> 
        <posId>880924 </posId> 
       </merchant> 
       <messageProperties> 
        <channel>01</channel> 
        <apiVersion>1</apiVersion> 
        <channelTypeCode>VPOS</channelTypeCode> 
        <networkCode>MULTIB</networkCode> 
        <serviceType>01</serviceType> 
        <timestamp>2014-10-31T13:58:49.2934+01:00</timestamp> 
       </messageProperties> 
      </arg0> 
     </fin:requestFinancialOperation> 
    </soapenv:Body> 
</soapenv:Envelope>'; 
    $result = $webService->requestFinancialOperation($data); 

我一直在尝试使用pem证书实现肥皂请求,我只是想出点点子。我知道我的代码应该都是错的,但我不知道什么是正确的方向。我一直在研究,但没有发现任何文档,我必须使用的webservice团队也无法提供帮助。带请求证书的PHP肥皂请求

我可以使用了SoapUI所以我知道web服务工作

回答

0

部分的问题是你发送XML时,你可能不需要该服务已经沟通。 PHP内置的SOAP客户端将为您处理XML,因此您可以专注于对象(SOAP中的O!)。您需要构建数据结构(对象或数组)并将其传递给您想要运行的操作。首先查找要使用操作的签名:

$webService = new SoapClient($url, $configs); 
var_dump($webService->__getFunctions()); 

这给你的API - 请注意,它表示,它预计在两个输入参数和输出的数据结构。要了解这些数据结构是这样的:

var_dump($webService->__getTypes()); 

现在,您可以构建一个PHP对象具有相同的字段和结构,并通过它在你的代码看起来会沿着这些路线:

$webService = new SoapClient($url, $configs); 
$parameter = new stdClass(); 
$parameter->someField = 'N0003'; 
$parameter->anotherField = 'TESTE'; 
$result = $webService->requestFinancialOperation($parameter);