Jump to content

SOAP CALL function from PHP


andriuxs

Recommended Posts

How to corectly define parameters in call function using PHP that I get this soap request:

    <soap:Body>

    <GetProductList xmlns="http://schemas.acme.eu/">

      <GetProductListRequest>

        <Filters>

          <Filter>

            <Name>Language</Name>

            <Value>lt-LT</Value>

          </Filter>

          <Filter>

            <Name>Currency</Name>

            <Value>LTL</Value>

          </Filter>

        </Filters>

      </GetProductListRequest>

    </GetProductList>

  </soap:Body>

 

I defined parameters this way: $par= array('Filter' => array('Name' => 'Language', 'Value' => 'lt-lt'), 'Filter' => array('Name' => 'Currency', 'Value' => 'LTL'))); and get error: System.NullReferenceException: Object reference not set to an instance of an object

Link to comment
https://forums.phpfreaks.com/topic/84083-soap-call-function-from-php/
Share on other sites

Yes i read it and other methods works fine if there is no parameters but then i call GetProductList method with defined parameters it returns an error. So it means that I have defined parameters incorrectly, and I don't no how to define them correctly, that I could get this request:

<GetProductList xmlns="http://schemas.acme.eu/">

      <GetProductListRequest>

        <Filters>

          <Filter>

            <Name>Language</Name>

            <Value>lt-LT</Value>

          </Filter>

          <Filter>

            <Name>Currency</Name>

            <Value>LTL</Value>

          </Filter>

        </Filters>

      </GetProductListRequest>

    </GetProductList>   

 

my php code:

 

$licenseKey = '498ec72c-e8e7-48f2-b300-d95666aeb141';

$soapClient = new soapclient_nusoap('https://api.acme.lt/0.1/commerce.asmx?WSDL', false);

$soapFault = $soapClient->getError();

if ($soapFault)

{

echo '<h2>Constructor error</h2><pre>' . $soapFault . '</pre>';

}

$soapClient->soap_defencoding = 'UTF-8';

$soapHeaders = '<LicenseHeader xmlns="http://schemas.acme.eu/"><LicenseKey>'.$licenseKey.'</LicenseKey></LicenseHeader>';

 

//I'd tried to define parameters in two ways but it doesn't worked.

$par= array('Filter' => array('Name' => 'Language', 'Value' => 'lt-lt'), 'Filter' => array('Name' => 'Currency', 'Value' => 'LTL'));

 

//$par = array('Name' => 'Language', 'Value' => 'lt-lt', 'Name' => 'Currency', 'Value' => 'LTL');  

 

// Make Request

//$result = $soapClient->call('GetVendorList', '', 'http://schemas.acme.eu/', 'http://schemas.acme.eu/GetVendorList', $soapHeaders); This works

//$result = $soapClient->call('GetProductClassification', '', 'http://schemas.acme.eu/', 'http://schemas.acme.eu/GetProductClassification', $soapHeaders); This works

$result = $soapClient->call('GetProductList', $par, 'http://schemas.acme.eu/', 'http://schemas.acme.eu/GetProductList', $soapHeaders);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.