Question 1:All Chinese characters received by the server are "????? "(Garbled)
Solution: Set the httprio. httpwebnode. userutf8inheader attribute of the httprio control to true.
Question 2:When a client compiled by dephi calls WebService in Windows2003, the following message is displayed: "access violation at address 00e59195. Write of address 00e59195"
Solution: choose my computer Properties> advanced> performance> Settings> Data Execution Protection. Select "enable Data Execution Protection for key Windows programs and services only. Of course, you can select another option and add our client as an exception. There are two strange points: 1. Not every Windows2003 machine needs to be set like this; 2. If there is a problem, 2003 machines can access WebService normally using clients written by. net.
Question 3:An error occurs when an analysis is performed on the XML string obtained from the server.
Solution: Use the widestring variable to save the returned XML string. Use this variable for analysis. String cannot recognize line breaks.
Question 4:All parameters obtained by the server are null.
Solution: Check whether the last three lines of the introduced WebService Unit are as follows:
Initialization
Invregistry. registerinterface (typeinfo (yourwebservicesoap), 'HTTP: // tempuri.org/', 'utf-8 ');
Invregistry. registerdefaultsoapaction (typeinfo (yourwebservicesoap), 'HTTP: // tempuri.org/?operationname= ');
Invregistry. registerinvokeoptions (typeinfo (yourwebservicesoap), iodocument); // This line sometimes does not have
End.
This line is invregistry. registerinvokeoptions (typeinfo (yourwebservicesoap), iodocument); sometimes it does not exist. For example, when one of our WebService methods has a parameter type of dataset, the last few lines of the unit file are as follows:
Initialization
Invregistry. registerinterface (typeinfo (yourwebservicesoap), 'HTTP: // tempuri.org/', 'utf-8 ');
Invregistry. registerdefaultsoapaction (typeinfo (yourwebservicesoap), 'HTTP: // tempuri.org/?operationname= ');
Remclassregistry. registerxsclass (getdatasetresult, 'HTTP: // tempuri.org/', getdatasetresult );
Remclassregistry. registerxsclass (updateset, 'HTTP: // tempuri.org/', 'updateset ');
End.
In this case, all parameters received by the server are null. Here you manually add the line mentioned above in the middle.
Question 5:Datetime returned by the server method. The time obtained by Delphi is incorrect.
Solution: After referencing, Delphi uses txsdatetime to receive the datetime variable of C. Txsdatetime has two attributes: asdatetime and asutcdatetime, both of which are tdatetime, that is, the date variable used by Delphi. However, the time obtained by these two attributes is incorrect. When you place a breakpoint, you can see that the year, month, and hour variables of txsdatetime are correct. Therefore, the solution is to re-combine the variables into time variables at the time of year and month.
In this process, I encountered an interesting situation. See the following C # code
[Webmethod (enablesession = true)]
Public datetime mytime ()
{
Datetime cur = datetime. now;
Return cur;
}
[Webmethod (enablesession = true)]
Public datetime yourtime (datetime ptime)
{
Return ptime. adddays (1 );
}
The time for storing the asdatetime attribute in txsdatetime is correct when Delphi calls the latter. When mytime () is called, the time saved by asdatetime is incorrect! I think asutcdatetime may be different, but here it is the same as asdatetime. In addition, what can. Net do? I noticed. net datetime has such a method touniversaltime; I tried to apply this method in mytime, and the result was worse. The value of each variable in Delphi was incorrect; it is expected that asutcdatetime will surprise me. The result is very consistent with that of asdatetime. The result is incorrect.