2016-11-25 150 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);