Send two txt fields via Soap using PHP

Asked

Viewed 203 times

0

I need to get the values of two fields from a file in .txt and send via Soap.

Sending Soap is already working, when I insert the Barcode and absoluteQuantity it sends the correct value, but now I need to make this field be fed by the file .txt, see image below.

inserir a descrição da imagem aqui

<?php    
    $client = new SoapClient('http://rcs01-sales.fftech.info/pub/apistock.asmx?wsdl');
    $function = 'BarcodeProcessAbsoluteQuantity';
    $arguments= array('BarcodeProcessAbsoluteQuantity' => array(
                        'Key'   => '5VWyXKYZxH0=',
                        'Barcode'                 => 8054182140865,
                        'absoluteQuantity'        => 2,
                        'ErrMsg'      => '0',
                        'IsAdjustment'      => '0',
                        'currentStock'      => '0',
                ));

    $options = array('location' => 'http://rcs01-sales.fftech.info/pub/apistock.asmx?wsdl');
    $result = $client->__soapCall($function, $arguments, $options);

    echo 'RESPOSTA:';
    print_r($result);
?>

1 answer

1

Just read the contents of the file using file_get_contents and traverse the lines by breaking \n and also ;.

$txtContent = "1;1\n2;2\n3;3"; // file_get_contents('file.txt');

$arrayContent = explode("\n", $txtContent);

foreach ($arrayContent as $string) {
    list($barcode, $absoluteQuantity) = explode(';', $string);

    echo "Bardcode {$barcode} with {$absoluteQuantity} quantity\n";
}

Live: http://sandbox.onlinephpfunctions.com/code/b88e59fbfd59f291bb343a218587434f2d84c436

  • Thanks Junior! Unfortunately using this way I have a problem with sending to the webservice (SOAP).

  • Ahn? What problem?

  • He just send the first line of the Barcode.

  • Then send this out of the loop, send your code.

  • The code looks like this: https://answall.com/a/237698/91056

  • And it’s wrong. The flame of SOAP should stay inside the foreach.

  • Friend, thank you very much !! IT WORKED.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.