EGL support for accessing SOAP headers

Several functions are available for accessing SOAP headers. For details on accessing HTTP headers, see the initial four reference topics at the end of this topic.

The SOAP headers are accessible only to an EGL-generated, Java-based SOAP service or to an EGL-generated, Java- or JavaScript-based SOAP service requester.

To see the flow of events, consider an example in which the SOAP headers are represented by the following Record part:
Record SOAPHeader
   field1 string{@xmlelement{namespace = "http://services"}};
   field2 string{@xmlelement{namespace = "http://services"}};
end 

The Record part must be non-structured, and each field must specify a namespace.

Here is the service code:
service SayHello {@soap{inputHeader = SOAPHeader, outputHeader = SOAPHeader}}
 function hello()
 getSOAPRequestHeaders(header);
 //...
 header SOAPHeader{field1="valueA", field2="valueB"};
 ServiceLib.setSOAPResponseHeaders(header);
 end
end 

The annotation @soap has two properties inputHeader and outputHeader that indicate which EGL record type corresponds to the respective header. These properties will be used to document the SOAP headers in the generated WSDL

The function hello retrieves the SOAP request headers into a record of the type shown earlier, assigns values to that record, and sets the SOAP response header with the requested values.

Here is requester code:
srvc SayHello{@BindService {}};
header SOAPHeader{field1="value1", field2="value2"};
ServiceLib.setSOAPRequestHeaders(srvc, header);
response string = srvc.hello("ABC");
ServiceLib.getSOAPResponseHeaders(srvc, header);

The requester declares a service-access variable, assigns values to a record of the type shown earlier, sets the SOAP request header with those values, invokes the service, and retrieves the response headers into a record of the type shown earlier.

Note:
The EGL-generated SOAP service or SOAP service requester must rely on JAX-WS rather than JAX-RPC.