SOAP DECLARATION

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 2004.3 (Modified)


SOAP DECLARATION (variable; type; input_output{; alias})

ParameterTypeDescription
variable4D variableVariable referring to an incoming
or outgoing SOAP argument
typeLongint4D type to which the argument points
input_outputLongint1 = SOAP Input, 2 = SOAP Output
aliasStringName published for this argument
during SOAP exchanges

Description

The SOAP DECLARATION command is used to explicitly declare 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 are used to 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; 4th Dimension uses the names "FourD_arg0, FourD_arg1 ... FourD_argn" by default.

This default operation can nevertheless prove to be problematic for the following reasons:

It is not possible to declare $0 or $1, $2, etc. as an array. Therefore, it is necessary to use pointers; however, in this case, the type of values must be known for the generation of the WSDL file.

Next, it can be useful or necessary to customize the parameter names (incoming and outgoing).

Also, returning values with a size greater than 32 KB (limit for Text arguments) can be necessary.

Finally, this operation makes it impossible to return more than one value per RPC call (in $0).

The SOAP DECLARATION command allows you to be free from these limits. You can execute this command for each incoming and outgoing parameter and assign it a name and a type.

Note: Even if the SOAP DECLARATION command is used, it is always 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. 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 4th Dimension, 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:

ConstantTypeValue
Is BLOBLongint30
Is BooleanLongint6
Is IntegerLongint8
Is LongIntLongint9
Is RealLongint1
Boolean arrayLongint22
String arrayLongint21
Date arrayLongint17
Integer arrayLongint15
LongInt arrayLongint16
Real arrayLongint14
Text arrayLongint18
Is TextLongint2
Is DateLongint4
Is TimeLongint11
Is String VarLongint24

Note: The following constants are not used in SOAP methods: Is Alpha Field, Is Pointer, Array 2D, Picture array, Pointer array, Is Picture, Is Subtable, Is Undefined.

In input_output, pass a value indicating whether the processed parameter is "incoming" (i.e. corresponding to a value received by the method) or "outgoing" (i.e. corresponding to a value returned by the method). You can use the following predefined constants, located in the "Web Services (Server)" theme:

ConstantTypeValue
SOAP InputLongint1
SOAP OutputLongint2

COMPILER_WEB method: 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 Web Services, Special 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).

If the alias parameter is omitted, 4th Dimension will use, by default, the name of the variable or FourD_argN for the 4D method arguments ($0 to $n).

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.

Examples

1. This example specifies a parameter name:

      ` In the COMPILER_WEB method
   C_LONGINT($1)

      ` In the Web Service method
      ` During generation of the WSDL file and SOAP calls, the word 
      ` zipcode will be used instead of fourD_arg1
   SOAP DECLARATION($1;Is LongInt;SOAP Input;"zipcode")

2. This example is used to retrieve an array of zip codes in the form of longints:

   `In the COMPILER_WEB method 
   ARRAY LONGINT(codes;0)

   `In the Web service method
   SOAP DECLARATION(codes;LongInt array;SOAP Input;"in_codes")

3. This example is used to refer to two return values without specifying an argument name:

   SOAP DECLARATION(ret1;Is LongInt;SOAP Output)
   SOAP DECLARATION(ret2;Is LongInt;SOAP Output)

4. This example allows the 4D SOAP server to return an argument with a size greater than 32 KB:

   C_BLOB($0)
   SOAP DECLARATION($0; Is Text; SOAP Output)

Note the type Is Text (and not Is BLOB). This allows the argument to be correctly processed.

See Also

Get SOAP info, Is data file locked, SEND SOAP FAULT.

Constants

Field and Variable Types and Web Services (Server) themes.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next