1

I have this request and I need to get response from the server but getting NULL

$XML = "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:esh="http://eshop.gf.lt/">
   <soapenv:Header/>
   <soapenv:Body>
      <esh:StartDealSession_v2>
         <product>EL</product>
         <merchantId>some_id</merchantId>
         <orderNo>123</orderNo>
         <totalAmount>790.90</totalAmount>
         <totalAmountCurrency>EUR</totalAmountCurrency>
         <totalAmountCurrRate>1.00</totalAmountCurrRate>
         <loanAdvance>0</loanAdvance>
         <sKey>password</sKey>
         <basket>
            <!--1 or more repetitions:-->
            <item>
               <code>1112</code>
               <type>KIT</type>
               <title>TEST</title>
               <category>KIT</category>
               <service>GDT</service>
               <sum>790.90</sum>
               <amount>1</amount>
               <currency>EUR</currency>
               <rate>1.00</rate>
            </item>
         </basket>
         <returnUrl>www.myshop.com/callback</returnUrl>
      </esh:StartDealSession_v2>
   </soapenv:Body>
</soapenv:Envelope>";

I'm creating new soap client:

$soap = new SoapClient($soapclient_link_wsdl, array('trace' => 1));

and do request:

   try {
            $result = $soap->__doRequest($XML, $soaprequest_link, 'StartDealSession_v2', 0);
            if (!$result) {
            return $result;
        } else {
            return false;
        }

    } catch (Exception $e) {
        $e = 0;
        return $e;
     } 

Response should be:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:StartDealSession_v2Response xmlns:ns2="http://eshop.gf.lt/">
         <return>
            <dealSessionId>D5C5123F30C20509E043C476A8C03B13</dealSessionId>
            <resultCode>1</resultCode>
         </return>
      </ns2:StartDealSession_v2Response>
   </S:Body>
</S:Envelope>

But $result receiving NULL. This I need to use in Virtuemart (JOOMLA)custom payment module

Can anybody help to solve this problem? What wrong in my code?

K. B.
  • 1,388
  • 2
  • 13
  • 25
  • You should check if there are any exceptions being thrown: `$soap = new SoapClient($soapclient_link_wsdl, array('trace' => 1, 'exceptions' =>1));` vs returning `0`. Also is this a typo? `if(!$result){return $result;}` – Kisaragi Feb 28 '18 at 21:03
  • I have tried your suggestion but nothing help... – K. B. Feb 28 '18 at 21:20
  • You don't need to use XML if you're using the PHP `SoapClient`. You need to send an object or array. Duplicate of this question: https://stackoverflow.com/questions/11593623/how-to-make-a-php-soap-call-using-the-soapclient-class – jjok Mar 01 '18 at 10:12
  • For all! My code working fine. Only I make mistake in my real enviroment. Sorry... – K. B. Mar 02 '18 at 08:41

0 Answers0