SOAP
| Home | Technical | FAQ | Links | Help | About |
| Database | Scripting | Objects | CSP | Zen | SQL | Bindings | MultiValue | System Management |
SOAP Server
XMLIGNORENULL
By default, the Cache SOAP Server will distinguish between elements that are null and elements that are missing. This is probably not what you want to happen and is generally unexpected behaviour!
For example, if your SOAP request contains:
<patient> <firstName>Gordon</firstName> <middleInitial>W</middleInitial> <surname>Brown</surname> </patient>
Then your patient object will contain:
USER>zzw oPatient [1@HIS.Patient] Id = - firstName = Gordon - middleInitial = W - surname = Brown
which is what you would expect.
And if your SOAP request contains:
<patient> <firstName>Gordon</firstName> <surname>Brown</surname> </patient>
Then your patient object will contain:
USER>zzw oPatient [1@HIS.Patient] Id = - firstName = Gordon - middleInitial = - surname = Brown
which is also what you would expect.
However, if you SOAP request contains:
<patient> <firstName>Gordon</firstName> <middleInitial></middleInitial> <surname>Brown</surname> </patient>
Then your patient object will contain:
USER>zzw oPatient [1@HIS.Patient] Id = - firstName = Gordon - middleInitial = $c(0) - surname = Brown
which you probably will not be expecting!
This can easily trip-up casual users who might not test their SOAP service with all possible permutations of input, and it complicates most code if you have to cater for every property potentially having a value of $c(0).
You can change the behaviour of the SOAP service by adding the following parameter to your SOAP server class:
Parameter XMLIGNORENULL = 1;
With this parameter set, then SOAP requests like this:
<patient> <firstName>Gordon</firstName> <middleInitial></middleInitial> <surname>Brown</surname> </patient>
will create a patient object like this:
USER>zzw oPatient [1@HIS.Patient] Id = - firstName = Gordon - middleInitial = - surname = Brown
In general you probably want XMLIGNORENULL=1 for most SOAP server implementations. Only if you need to distinguish between a missing element and a null element should you need XMLIGNORENULL=0.
To avoid forgetting to do this you can create a sub-class of %SOAP.WebService (and EnsLib.SOAP.Service) that overrides the default value of the XMLIGNORENULL parameter. You can then create all your web-services by sub-classing from this instead.
Debugging
You can get a SOAP Server hosted by Cache to log the contents of the SOAP request to a file by setting the following global nodes:
s ^ISCSOAP("LogFile")="someFile.log"
s ^ISCSOAP("Log")="i"
The ^ISCSOAP global is hidden, by default, so don't forget about it and leave it in your production system by mistake.