4D v16.3SOAP DECLARATION |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16.3
SOAP DECLARATION
SOAP DECLARATION
The SOAP DECLARATION command explicitly declares the type of parameters used in a 4D method published as a Web Service. When a method is published as a Web Service, the standard parameters $0, $1... $n describe the parameters of the Web Service to the outside world (more particularly in the WSDL file). The SOAP protocol requires that parameters be explicitly named; 4D uses the names “FourD_arg0, FourD_arg1 ... FourD_argn” by default. This default operation can nevertheless prove to be problematic for the following reasons:
The SOAP DECLARATION command lets you be free from these limits. You can execute this command for each incoming and outgoing parameter to assign it a name and a type. Note: Even when the this command is used, it is still necessary to declare 4D variables and arrays in the Compiler_Web method using commands of the “Compiler” theme. In variable, pass the 4D variable to be referred to when calling the Web Service. Warning: You can only refer to process variables or 4D method arguments ($0 to $n). Local and interprocess variables cannot be used. By default, because only Text type arguments can be used, the SOAP server responses are limited to 32 KB in databases that are in non-Unicode mode. However, it is possible to return SOAP arguments with a size greater than 32 KB, using BLOBs. To exceed this limit, you simply need to declare the arguments as BLOBs before calling the SOAP DECLARATION command (see example 4). Note: On the client side, if you subscribe to this type of Web Service with 4D, the Web Services Wizard will of course generate a Text type variable. To be able to use it, you just need to re-type this return variable as a BLOB in the proxy method. In type, pass the corresponding 4D type. Most types of 4D variables and arrays can be used. You can use the following predefined constants, located in the “Field and Variable Types” theme, as well as, for XML types, two constants of the Web Services (Server) theme:
You can declare variables of the "XML structure" and "DOM reference" type, both incoming and outgoing, via the Is XML and Is DOM reference constants. When parameters of this type are specified, no processing or encoding is applied to them and the data are transmitted "as is" (see example 5).
Note: In the case of DOM references used as outgoing parameters, it is recommended to use global references, created, for example, on startup and closed when the application is closed. In fact, a DOM reference created within the Web Service itself cannot be closed with DOM CLOSE XML, otherwise the Web Service no longer returns anything. Multiple calls to the Web Service therefore involve creating multiple unclosed DOM references, which can lead to memory saturation
Incoming SOAP arguments referred to using 4D variables (and not 4D method arguments) must first be declared in the COMPILER_WEB project method. In fact, the use of process variables in Web Services methods requires that they be declared before the method is called. The COMPILER_WEB project method is called, if it exists, for each SOAP request accepted. By default, the COMPILER_WEB method does not exist. You must specifically create it. Note that the COMPILER_WEB method is also called by the 4D Web server when receiving “conventional” Web requests of the POST type (see URLs and Form Actions section). In alias, pass the name of the argument as it must appear in the WSDL and in the SOAP exchanges. Warning: This name must be unique in the RPC call (both input and output parameters taken together), otherwise, only the last declaration will be taken into account by 4D. Note: The argument names must not begin with a number nor contain spaces. Moreover, to avoid any risks of incompatibility, it is recommended to not use extended characters (such as accented characters). Note: The SOAP DECLARATION command must be included in the method published as a Web Service. It is not possible to call it from another method. This example specifies a parameter name: ` In the COMPILER_WEB method This example retrieves an array of zip codes in the form of longints: `In the COMPILER_WEB method This example refers to two return values without specifying an argument name: SOAP DECLARATION(ret1;Is longint;SOAP output) This example allows the 4D SOAP server to return an argument with a size greater than 32 KB in databases in non-Unicode mode: C_BLOB($0)
This example illustrates the results of different types of declarations: ALL RECORDS([Contact])
See also
|
PROPERTIES
Product: 4D
HISTORY
Modified: 4D v11 SQL Release 2 ARTICLE USAGE
4D Language Reference ( 4D v16) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||