NuSOAP PHP web service and sending large string

116 views Asked by At

again i am seeking for you help! I am new to NuSOAP, so please bear with me. I am trying to send multiple records, with multiple columns to my service, split this into records and writting them into my sql table.

For example, i have a batch that updates my variable like so (records are separated with ";", columns inside records are separated with "¤")

Name1¤Surname1¤Date1¤number1;Name2¤Surname2¤Date2¤number2;Name3¤Surname3¤Date3¤number3 ...

I have a simple function which accepts this variable. (1st of all i dont know if sending a string is optimal ... I read that i should be sending an xml document ...)

So if i declare a new variable inside my script and past the exact value that my program sets up, execute the script, everything works! Records are written in a table without any problem. I wrote up to 500 records. The problem is when i call my webservice ... In that case i get an error:

"SOAP Fault: error in msg parsing: XML error parsing SOAP payload on line 1: Invalid character:"

I think i am sending a to many chars in my variable ... Again i am new to NuSOAP and i am trying to figure this out based on an example i found online ...

When i was sending just text with only 1 delimeter, i was able to sent and write 500 records. The variable was setup like so: TEST001;TEST002;TEST003; ...;TEST500

And the web service recieved the variable and wrote all 500 records to the table. Can someone please help me out or tell me the correct way of doing this?

Regards, HEki

<?php
require 'lib/nusoap.php';
$server = new nusoap_server();
$server->configureWSDL("test"."urn:test");
$server->register(
            "service",
            array("variable_text"=>'xsd:string'),
            array("return"=>"xsd:string")
        );
        
function service($variable_text)
{
    $mysql_hostname = "localhost";
    $mysql_user = "root";
    $mysql_password = "root";
    $mysql_database = "service";

    $today = date("Y-m-d");
    
    $response='START';
    
    // Connect to database server

    $con = mysqli_connect($mysql_hostname, $mysql_user, $mysql_password, $mysql_database);
    
    if (mysqli_connect_errno()) {
    echo "ERROR: " . mysqli_connect_error();
    }
    
    $token = strtok($variable_text, ";");
 
    while ($token !== false) 
        {
            $data = explode('¤', $token);
            $data0 = $data[0];
            $data1 = $data[1];
            $data2 = $data[2];
            $data3 = (int)$data[3];
            $strSQL = "INSERT INTO test (column1,column2,column3,column4) VALUES ('".$data0."','".$data1."','".$data2."', '".$data3."')";
            mysqli_query($con,$strSQL);
            $response='NEW';
            $token = strtok(";");
        }   

    // Close the database connection

    mysqli_close($con);

    return $response;
    
}
        
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?> 
0

There are 0 answers