0 votes
in SoSci Survey (English) by s057462 (330 points)

Hi again,
it looks like we have trouble reading the sent xml data on the server.
We currently send:

$xml.= '<myData attr="ID”>'
$xml.= '<data attr="'.id('S101', $n+1).'">'.htmlspecialchars(value(id('S101', $n+1))).'</data>\n'
$xml.= '<data attr="'.id('S102', $n+1).'">'.htmlspecialchars(value(id('S102', $n+1))).'</data>\n'
$xml.= '</myData>'
$answer = sendXML('http://dd.virtualpsyclab.net/ddgem/ddgem', $xml)['children'][1];

and what comes in at the other end starts with:

<?xmlversion="1.0"encoding="UTF-8"?><myDataattr="ID">124<saveEnvsave="false"/><dataattr="S101_01">2</data>"\n".break<dataattr="S101_02">2</data>"\n".break<dataattr="S101_03">2</data>"\n"

We think that because of the missing spaces, the receiving end cannot properly read it (and throws back a response that is given when the responses are "unreasonable":
STOP -99 -99 -99 ....

Two questions:
1) is there anything you see in our sent information that needs to be different, e.g. quotes/types of quotes?
2) is there a quicker way to debug other than always running all the questions before getting to the sending stage (i.e. send random data or so)?

Thank you for your help.
Hedwig

1 Answer

0 votes
by SoSci Survey (302k points)

We think that because of the missing spaces

That was also my guess. What makes me think are the typgraphic quotation marks:

$xml.= '<myData attr="ID”>'

Correct would be:

$xml.= '<myData attr="ID">';

Such quotation marks often occur if you write code in Word, because Word does all kinds of "optimization" to the text. Possilby it also has exchanged the spaces for other spacers that look the same, but have a different meaning in programming.

Have you tries to exchange the space in the above example directly in SoSci Survey? If that does the trick, consider working on the code in a different software. Either directly in SoSci Survey or in Notepad++ or some other plain-text editor.

2) is there a quicker way to debug other than always running all the questions before getting to the sending stage (i.e. send random data or so)?

Sure. Set the data for debugging:

put('S101', 1, true);
put('S102', 2, true);
$n = 10;

$xml = ...
by s057462 (330 points)
Thank you, we edited all spaces and quotes within the soscisurvey ph editing filed , but still get the "unspaced" output:
<?xmlversion="1.0"encoding="UTF-8"?><myDataattr="ID">144<saveEnvsave="false"/><dataattr="S101_01">1</data>"\n"<dataattr="S101_02">1</data>"\n"<dataattr="S101_03">1</data>"\n"<dataattr="S101_04">1</data>"\n"<dataattr="S101_05"> ...

(thanks for the hint for (2), super helpful!)
by s057462 (330 points)
We found out what went wrong on the server side and tis is what works:
    $xml.= '<data attr="'.id('S102', $n+1).'">'.htmlspecialchars(value(id('S102', $n+1))).'</data>'."\r\n";
by SoSci Survey (302k points)
edited by SoSci Survey
Okay, I have created a script to allow for testing requests:
https://www.soscisurvey.de/tools/post-monkey.php

You can send the request there and take a look what is received.

I have tried this PHP code and confirmed that the spaces were sent properly:

$xml = '<?xml version="1.0"?'.'>';
$xml.= '<myData attr="ID">';
$xml.= '<data attr="ID01">'.htmlspecialchars(1).'</data>\n';
$xml.= '<data attr="ID02">'.htmlspecialchars(2).'</data>\n';
$xml.= '</myData>';
$answer = sendXML('https://www.soscisurvey.de/tools/post-monkey.php?id=YG...', $xml);

You can get an URL from the above script and insert in in your PHP code in sendXML().

If the request is received correctly by that tool, but not correctly on your server, it is very likely that the spaces are removed by your server. Possibly a misleaded string sanitation feature?
by SoSci Survey (302k points)
> We found out what went wrong on the server sid

Bad timing :D

Well, let's hope the tool can spare other some work, then.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...