Genivia Home Documentation
Context with engine state

updated Sun Jan 20 2019 by Robert van Engelen
 
Context with engine state

This module defines the soap context structure with the engine state and functions to allocate, initialize, copy and delete contexts. More...

Classes

struct  soap
 Context with the engine state. More...
 

Functions

struct soapsoap_new ()
 Allocate and initialize a new soap context. More...
 
struct soapsoap_new1 (soap_mode input_and_output_mode)
 Allocate and initialize a new soap context with input and output soap_mode flags. More...
 
struct soapsoap_new2 (soap_mode input_mode, soap_mode output_mode)
 Allocate and initialize a new soap context with separate input and output soap_mode flags. More...
 
void soap_init (struct soap *soap)
 Initialize a stack-allocated soap context. More...
 
void soap_init1 (struct soap *soap, soap_mode input_and_output_mode)
 Initialize a stack-allocated soap context with input and output soap_mode flags. More...
 
void soap_init2 (struct soap *soap, soap_mode input_mode, soap_mode output_mode)
 Initialize a stack-allocated soap context with input and output soap_mode flags. More...
 
void soap_set_mode (struct soap *soap, soap_mode input_and_output_mode)
 Set input and output soap_mode flags of the given soap context. More...
 
void soap_set_imode (struct soap *soap, soap_mode input_mode)
 Set input soap_mode flags of the given soap context. More...
 
void soap_set_omode (struct soap *soap, soap_mode output_mode)
 Set output soap_mode flags of the given soap context. More...
 
void soap_clr_mode (struct soap *soap, soap_mode input_and_output_mode)
 Clear input and output soap_mode flags of the given soap context. More...
 
void soap_clr_imode (struct soap *soap, soap_mode input_mode)
 Clear input soap_mode flags of the given soap context. More...
 
void soap_clr_omode (struct soap *soap, soap_mode output_mode)
 Clear output soap_mode flags of the given soap context. More...
 
struct soapsoap_copy (struct soap *soap)
 Allocate and initialize a new soap context as a copy of the given soap context. More...
 
void soap_copy_context (struct soap *soap_destination, struct soap *soap_source)
 Copy a given soap context to an uninitialized destination soap context. More...
 
void soap_copy_stream (struct soap *soap_destination, struct soap *soap_source)
 Copy the input/output stream state of the given soap context to another context. More...
 
void soap_free_stream (struct soap *soap)
 Free the input/output stream state of the given soap context. More...
 
void soap_free (struct soap *soap)
 Finalize and free the given soap context from unmanaged heap memory. More...
 
void soap_done (struct soap *soap)
 Finalize the given soap context, i.e. when the soap context is stack allocated, automatically invoked in C++ by the soap destructor on the soap context to delete. More...
 
void * soap_malloc (struct soap *soap, size_t len)
 Allocate a block of heap memory managed by the specified soap context. More...
 
char * soap_strdup (struct soap *soap, const char *string)
 Copy a string to managed memory. More...
 
wchar_t * soap_wstrdup (struct soap *soap, const wchar_t *string)
 Copy a wide string to managed memory. More...
 
int soap_unlink (struct soap *soap, const void *ptr)
 Unlink a block of heap memory managed by the specified soap context, to release the memory explicitly later. More...
 
void soap_destroy (struct soap *soap)
 Delete all dynamically-allocated C++ objects managed by the specified soap context. More...
 
void soap_dealloc (struct soap *soap, void *ptr)
 Explicitly dealllocates a block of managed memory that is managed by the specified soap context and release the free memory back to the heap. More...
 
void soap_free_temp (struct soap *soap)
 Delete temporary data. More...
 
void soap_end (struct soap *soap)
 Delete all data from heap memory managed by the specified soap context and release the freed memory back to the heap. More...
 
void soap_delegate_deletion (struct soap *soap, struct soap *soap_to)
 Delegate the deletion of all managed objects and data from the specified soap context to another soap context. More...
 
void soap_set_version (struct soap *soap, short version)
 Set SOAP version (0 = no SOAP, 1 = SOAP 1.1, 2 = SOAP 1.2) More...
 

Detailed Description

This module defines the soap context structure with the engine state and functions to allocate, initialize, copy and delete contexts.

Function Documentation

◆ soap_clr_imode()

void soap_clr_imode ( struct soap soap,
soap_mode  input_mode 
)

Clear input soap_mode flags of the given soap context.

Parameters
soap`soap` context
input_modeinput `soap_mode` flags

◆ soap_clr_mode()

void soap_clr_mode ( struct soap soap,
soap_mode  input_and_output_mode 
)

Clear input and output soap_mode flags of the given soap context.

Parameters
soap`soap` context
input_and_output_modeinput and output `soap_mode` flags

◆ soap_clr_omode()

void soap_clr_omode ( struct soap soap,
soap_mode  output_mode 
)

Clear output soap_mode flags of the given soap context.

Parameters
soap`soap` context
output_modeoutput `soap_mode` flags

◆ soap_copy()

struct soap* soap_copy ( struct soap soap)

Allocate and initialize a new soap context as a copy of the given soap context.

This function allocates a new context and copies the state of the specified context except for the heap-allocated data managed by the specified context. After the copy the contexts do not share any data and can therefore be used by separate threads without requiring synchronization or mutex locking.

Note
C++ proxy and service classes generated by soapcpp2 -j option -j or option -i have an internal soap context that is either a base class (option -i) or a member variable pointing to a soap context (option -j). For convenience, use the copy member function instead of soap_copy and delete the copied instance with delete. For example:
#include "soapexampleService.h" // generated by soapcpp2 option -j
int main()
{
exampleService service(SOAP_XML_INDENT);
service.soap->bind_flags = SO_REUSEADDR; // immediate port reuse
service.soap->accept_timeout = 3600; // let soap_accept time out after 1 hour
... // further initialize service.soap
if (soap_valid_socket(service.bind(NULL, PORTNUM, BACKLOG)))
{
while (1)
{
if (soap_valid_socket(service.accept()))
{
exampleService *tservice = service.copy();
if (!tservice)
soap_closesock(service.soap);
else
while (THREAD_CREATE(&tid, (void*(*)(void*))&process_request, (void*)tservice))
sleep(1); // failed, try again
}
else if (service.soap->errnum) // accept failed, try again after 1 second
{
service.soap_print_fault(stderr);
sleep(1);
}
else // accept timed out, quit looping
{
break;
}
service.destroy();
}
}
}
void *process_request(exampleService *service)
{
service.serve();
service.destroy();
delete service;
return NULL;
}
Example:
#include "soapH.h"
#include "plugin/threads.h"
int main()
{
soap->bind_flags = SO_REUSEADDR; // immediate port reuse
soap->accept_timeout = 3600; // exit loop when no request arrives in one hour
soap->send_timeout = soap_recv_timeout = 5; // 5 seconds max socket stall time (unlimited by default)
soap->transfer_timeout = 30; // 30 seconds max message transfer time (unlimited by default)
soap->recv_maxlength = 1048576; // limit messages received to 1MB (2GB by default)
if (soap_valid_socket(soap_bind(soap, NULL, PORTNUM, BACKLOG)))
{
while (1)
{
{
struct soap *tsoap = soap_copy(soap);
if (!tsoap)
else
while (THREAD_CREATE(&tid, (void*(*)(void*))&process_request, (void*)tsoap))
sleep(1); // failed, try again
}
else // accept failed, try again after 1 second
{
sleep(1);
}
else // accept timed out, quit looping
{
break;
}
}
}
}
void *process_request(struct soap *soap)
{
return NULL;
}
See also
soap_copy_context, soap_copy_stream, soap_delegate_deletion, soap_destroy, soap_end, soap_free.
Returns
pointer to allocated and initialized soap context or NULL when out of heap memory
Parameters
soap`soap` context to copy

◆ soap_copy_context()

void soap_copy_context ( struct soap soap_destination,
struct soap soap_source 
)

Copy a given soap context to an uninitialized destination soap context.

This function copies the state of the specified context to another uninitialized context (i.e. overriding it). If the destination context is initialized or active then call soap_done first to clean it up before overriding it. The entire state is copied except for the heap-allocated data managed by the specified context. After the copy the contexts do not share any data and can therefore be used by separate threads without requiring synchronization or mutex locking.

Example:
#include "soapH.h"
struct soap *soap = soap_new();
... // send and receive messages etc.
struct soap temp;
...
See also
soap_copy, soap_copy_stream, soap_delegate_deletion, soap_destroy, soap_end, soap_free.
Parameters
soap_destinationdestination `soap` context to initialize
soap_sourcesource `soap` context to copy

◆ soap_copy_stream()

void soap_copy_stream ( struct soap soap_destination,
struct soap soap_source 
)

Copy the input/output stream state of the given soap context to another context.

Parameters
soap_destinationdestination `soap` context
soap_sourcesource `soap` context

◆ soap_dealloc()

void soap_dealloc ( struct soap soap,
void *  ptr 
)

Explicitly dealllocates a block of managed memory that is managed by the specified soap context and release the free memory back to the heap.

This function deallocates a managed block of memory from the managing soap context and releases the free memory back to the heap. This frees data allocated with soap_malloc and C++ objects allocated and instantiated with the soap_new_T functions. Normally this function should not be used to individually deallocate managed objects and data but rather soap_destroy and soap_end should be used to deallocate all objects and data managed by the context, which is much more efficient.

Parameters
soap`soap` context
ptrpointer to the block of managed heap memory to deallocate

◆ soap_delegate_deletion()

void soap_delegate_deletion ( struct soap soap,
struct soap soap_to 
)

Delegate the deletion of all managed objects and data from the specified soap context to another soap context.

This function moves all dynamically-allocated data managed by the specified soap context to the target context soap_to for deletion by the target context using soap_destroy and soap_end.

Example:
#include "soapH.h"
struct soap *soap = soap_new();
struct soap *temp = soap_new(); // temp context to manage data
if (soap_call_ns__webmethod(soap, endpoint, NULL, ...))
{
}
else
{
// success, response contains deserialized data
soap_delegate_deletion(soap, temp); // deserialized data is managed by temp context
}
soap_destroy(soap); // clean up 'soap' context
soap_end(soap); // clean up 'soap' context
... // use deserialized data managed by 'temp' context, reuse 'soap' context as needed
soap_destroy(temp); // clean up 'temp' context, deletes deserialized data
soap_end(temp); // clean up 'temp' context, deletes deserialized data
soap_free(temp);
See also
soap_copy, soap_copy_context, soap_destroy, soap_end.
Parameters
soapsource `soap` context
soap_totarget `soap` context

◆ soap_destroy()

void soap_destroy ( struct soap soap)

Delete all dynamically-allocated C++ objects managed by the specified soap context.

This function deletes all dynamically-allocated C++ objects managed by the specified soap context, i.e. data allocated with soap_new_T calls. This call should be followed by soap_end to delete all other dynamically-allocated data managed by the soap context. Or just invoke soap::destroy to delete objects and data and release the freed memory back to the heap.

Note
C++ proxy and service classes generated by soapcpp2 -j option -j or option -i have an internal soap context that is either a base class (option -i) or a member variable pointing to a soap context (option -j). For convenience, use the destroy member function instead of soap_destroy and soap_end. For example:
#include "soapexampleProxy.h"
exampleProxy proxy(SOAP_XML_INDENT);
... // use proxy or proxy.soap (option -j)
proxy.destroy(); // delete managed C++ objects and memory
#include "soapexampleService.h"
exampleService service(SOAP_XML_INDENT);
... // use service or service.soap (option -j)
service.destroy(); // delete managed C++ objects and memory
Example:
#include "soapH.h"
struct soap *soap = soap_new();
... // send and receive messages etc.
soap_destroy(soap); // delete managed C++ objects
soap_end(soap); // delete managed memory
soap_free(soap); // free the context
See also
soap_malloc, soap_end, soap::destroy.
Parameters
soap`soap` context

◆ soap_done()

void soap_done ( struct soap soap)

Finalize the given soap context, i.e. when the soap context is stack allocated, automatically invoked in C++ by the soap destructor on the soap context to delete.

This function finalizes the specified context. This function does not free memory managed by the context. To free memory managed by the context use soap_destroy and soap_end, or soap::destroy to call both.

Example:
#include "soapH.h"
struct soap soap;
... // send and receive messages etc.
See also
soap_free, soap_destroy, soap_end, soap::destroy.
Parameters
soap`soap` context to finalize

◆ soap_end()

void soap_end ( struct soap soap)

Delete all data from heap memory managed by the specified soap context and release the freed memory back to the heap.

This function deletes all dynamically-allocated data managed by the specified soap context, i.e. data allocated with soap_malloc. This call suffices to delete all managed data from C applications and release the freed memory back to the heap. C++ applications however should call soap_destroy first before soap_end or just invoke soap::destroy (or C++ proxy and service class member function destroy) to delete objects and data and release the freed memory back to the heap.

Note
C++ proxy and service classes generated by soapcpp2 -j option -j or option -i have an internal soap context that is either a base class (option -i) or a member variable pointing to a soap context (option -j). For convenience, use the destroy member function instead of soap_destroy and soap_end. For example:
#include "soapexampleProxy.h"
exampleProxy proxy(SOAP_XML_INDENT);
... // use proxy or proxy.soap (option -j)
proxy.destroy(); // delete managed C++ objects and memory
#include "soapexampleService.h"
exampleService service(SOAP_XML_INDENT);
... // use service or service.soap (option -j)
service.destroy(); // delete managed C++ objects and memory
Example:
#include "soapH.h"
struct soap *soap = soap_new();
... // send and receive messages etc.
soap_destroy(soap); // delete managed C++ objects
soap_end(soap); // delete managed memory
soap_free(soap); // free the context
See also
soap_malloc, soap_destroy, soap::destroy.
Parameters
soap`soap` context

◆ soap_free()

void soap_free ( struct soap soap)

Finalize and free the given soap context from unmanaged heap memory.

This function finalizes and frees the specified context. The finalization is done with soap_done before releasing its memory. This function does not free memory managed by the context. To free memory managed by the context use soap_destroy and soap_end, or soap::destroy to call both.

Note
C++ proxy and service classes generated by soapcpp2 -j option -j or option -i have an internal soap context that is either a base class (option -i) or a member variable pointing to a soap context (option -j). The C++ proxy and service classes allocate and deallocate this context, which means that soap_new and soap_free are not required. For example:
#include "soapexampleProxy.h"
exampleProxy proxy(SOAP_XML_INDENT);
... // use proxy or proxy.soap (option -j)
proxy.destroy(); // delete managed C++ objects and memory
#include "soapexampleService.h"
exampleService service(SOAP_XML_INDENT);
... // use service or service.soap (option -j)
service.destroy(); // delete managed C++ objects and memory
Example:
#include "soapH.h"
struct soap *soap = soap_new();
... // send and receive messages etc.
See also
soap_new, soap_new1, soap_new2, soap_done, soap_destroy, soap_end, soap::destroy.
Parameters
soap`soap` context to free

◆ soap_free_stream()

void soap_free_stream ( struct soap soap)

Free the input/output stream state of the given soap context.

See also
soap_copy_stream.
Parameters
soap`soap` context

◆ soap_free_temp()

void soap_free_temp ( struct soap soap)

Delete temporary data.

This function deallocates temporary data such as buffers and hash tables but leaves deserialized managed data intact.

Parameters
soap`soap` context

◆ soap_init()

void soap_init ( struct soap soap)

Initialize a stack-allocated soap context.

This function initializes a context.

Examples:
#include "soapH.h"
struct soap soap;
... // send and receive messages etc.
soap_destroy(&soap); // delete managed C++ objects
soap_end(s&oap); // delete managed memory
soap_done(&soap); // finalize the context

The context can be re-initialized for reuse after soap_done by calling soap_init.

Note
Initialization should be done at most once before calling soap_done. To change the input/output mode flags, use soap_set_mode and soap_clr_mode.
See also
soap_init1, soap_new, soap_copy, soap_destroy, soap_end, soap_done.
Parameters
soap`soap` context to initialize

◆ soap_init1()

void soap_init1 ( struct soap soap,
soap_mode  input_and_output_mode 
)

Initialize a stack-allocated soap context with input and output soap_mode flags.

This function initializes a context with the specified input and output soap_mode flags.

Examples:
#include "soapH.h"
struct soap soap;
... // send and receive messages etc.
soap_destroy(&soap); // delete managed C++ objects
soap_end(s&oap); // delete managed memory
soap_done(&soap); // finalize the context

The context can be re-initialized for reuse after soap_done by calling soap_init.

Note
Initialization should be done at most once before calling soap_done. To change the input/output mode flags, use soap_set_mode and soap_clr_mode.
See also
soap_init, soap_new, soap_copy, soap_destroy, soap_end, soap_done.
Parameters
soap`soap` context to initialize
input_and_output_modeinput and output `soap_mode` flags

◆ soap_init2()

void soap_init2 ( struct soap soap,
soap_mode  input_mode,
soap_mode  output_mode 
)

Initialize a stack-allocated soap context with input and output soap_mode flags.

This function initializes a context with the specified input and output soap_mode flags.

Note
Initialization should be done at most once before calling soap_done. To change the input/output mode flags, use soap_set_mode and soap_clr_mode.
See also
soap_init, soap_new, soap_copy, soap_destroy, soap_end, soap_done.
Parameters
soap`soap` context to initialize
input_modeinput `soap_mode` flags
output_modeoutput `soap_mode` flags

◆ soap_malloc()

void* soap_malloc ( struct soap soap,
size_t  len 
)

Allocate a block of heap memory managed by the specified soap context.

This function allocates a block of memory from the heap managed by the specified soap context. All such blocks allocated are deleted with a single call to soap_end. Returns a pointer to the allocated block of memory or NULL when out of memory without setting soap::error.

Note
The soapcpp2 tool generates soap_new_T functions for all serialiable types T. The soap_new_T functions allocate and default initializes the type T or an array of items of type T. Recommended is to use these more powerful soap_new_T functions instead of soap_malloc. For example:
#include "soapH.h"
struct soap *soap = soap_new();
struct ns__someElement *data = soap_new_ns__someElement(soap); // allocate managed object
struct ns__someElement *array = soap_new_ns__someElement(soap, 100); // allocate array of 100 managed objects
... // send and receive messages etc.
soap_destroy(soap); // deletes data, array, and other managed C++ objects
soap_end(soap); // delete managed memory
soap_free(soap); // free the context

The soapcpp2 tool also generates soap_default_T functions to default initialize the type T. For example:

#include "soapH.h"
struct soap *soap = soap_new();
struct ns__someElement data;
soap_default_ns__someElement(soap, &data); // default initializes all public members
...

but objects of classes should use their soap_default method instead of the soap_default_T function.

Example:
#include "soapH.h"
struct soap *soap = soap_new();
char *s = (char*)soap_malloc(soap, 80); // allocate 80 bytes of memory managed by the context
strcpy(s, "Hello"); // copy a string into it
... // send and receive messages etc.
soap_destroy(soap); // delete managed C++ objects
soap_end(soap); // delete managed memory
soap_free(soap); // free the context
See also
soap_strdup, soap_wstrdup, soap_unlink, soap_delegate_deletion, soap_destroy, soap_end, and the C and C++ XML data bindings documentation.
Returns
pointer to the allocated block of memory or NULL on failure to allocate (out of memory)
Parameters
soap`soap` context
lenlength of the block to allocate in number of bytes

◆ soap_new()

struct soap* soap_new ( )

Allocate and initialize a new soap context.

This function allocates and initializes a new context.

There is no need to call soap_init to initialize the context allocated with soap_new, since soap_new initializes the allocated context. To change the input/output mode flags, use soap_set_mode and soap_clr_mode.

Note
C++ proxy and service classes generated by soapcpp2 -j option -j or option -i have an internal soap context that is either a base class (option -i) or a member variable pointing to a soap context (option -j). The C++ proxy and service classes allocate and deallocate this context, which means that soap_new and soap_free are not required. For example:
#include "soapexampleProxy.h"
exampleProxy proxy(SOAP_XML_INDENT);
... // use proxy or proxy.soap (option -j)
proxy.destroy(); // delete managed C++ objects and memory
#include "soapexampleService.h"
exampleService service(SOAP_XML_INDENT);
... // use service or service.soap (option -j)
service.destroy(); // delete managed C++ objects and memory
Example:
#include "soapH.h"
struct soap *soap = soap_new();
... // send and receive messages etc.
soap_destroy(soap); // delete managed C++ objects
soap_end(soap); // delete managed memory
soap_free(soap); // free the context
See also
soap_new1, soap_new2, soap_copy, soap_destroy, soap_end, soap_free.
Returns
pointer to allocated and initialized soap context or NULL when out of heap memory

◆ soap_new1()

struct soap* soap_new1 ( soap_mode  input_and_output_mode)

Allocate and initialize a new soap context with input and output soap_mode flags.

This function allocates and initializes a new context with the specified input and output soap_mode flags.

Example:
#include "soapH.h"
... // send and receive messages etc.
soap_destroy(soap); // delete managed C++ objects
soap_end(soap); // delete managed memory
soap_free(soap); // free the context
Note
There is no need to call soap_init to initialize the context allocated with soap_new1. To change the input/output mode flags, use soap_set_mode and soap_clr_mode.
See also
soap_new, soap_new2, soap_copy, soap_destroy, soap_end, soap_free.
Returns
pointer to allocated and initialized soap context or NULL when out of heap memory
Parameters
input_and_output_modeinput and output `soap_mode` flags

◆ soap_new2()

struct soap* soap_new2 ( soap_mode  input_mode,
soap_mode  output_mode 
)

Allocate and initialize a new soap context with separate input and output soap_mode flags.

This function allocates and initializes a new context with the specified input and output soap_mode flags. The separation of input and output mode flags is only useful for the SOAP_XML_TREE flag that affects both input and output behaviors.

Note
There is no need to call soap_init to initialize the context allocated with soap_new2.
See also
soap_new, soap_new1, soap_copy, soap_destroy, soap_end, soap_free.
Returns
pointer to allocated and initialized soap context or NULL when out of heap memory
Parameters
input_modeinput `soap_mode` flags
output_modeoutput `soap_mode` flags

◆ soap_set_imode()

void soap_set_imode ( struct soap soap,
soap_mode  input_mode 
)

Set input soap_mode flags of the given soap context.

Parameters
soap`soap` context
input_modeinput `soap_mode` flags

◆ soap_set_mode()

void soap_set_mode ( struct soap soap,
soap_mode  input_and_output_mode 
)

Set input and output soap_mode flags of the given soap context.

Parameters
soap`soap` context
input_and_output_modeinput and output `soap_mode` flags

◆ soap_set_omode()

void soap_set_omode ( struct soap soap,
soap_mode  output_mode 
)

Set output soap_mode flags of the given soap context.

Parameters
soap`soap` context
output_modeoutput `soap_mode` flags

◆ soap_set_version()

void soap_set_version ( struct soap soap,
short  version 
)

Set SOAP version (0 = no SOAP, 1 = SOAP 1.1, 2 = SOAP 1.2)

This function sets (or overrides) the SOAP version to use when sending a message. This function can be used prior to a client-side call to select the SOAP version to use for the request message (assuming the generated code does not fix the version already) or in a service operation to select the SOAP version of the response message. The response message of a service operation normally uses the same SOAP version of the SOAP request message received.

Parameters
soap`soap` contexr
versionSOAP version (0 = REST (no SOAP), 1 = SOAP 1.1, 2 = SOAP 1.2)

◆ soap_strdup()

char* soap_strdup ( struct soap soap,
const char *  string 
)

Copy a string to managed memory.

This function copies the specified wide string to memory managed by the specified context. Returns a copy of the string or NULL when the specified string is NULL or when the function failed to allocate memory.

Example:
#include "soapH.h"
struct soap *soap = soap_new();
// allocate and assign a string in memory managed by the context
char *s = soap_strdup(soap, "Hello");
... // send and receive messages etc.
soap_destroy(soap); // delete managed C++ objects
soap_end(soap); // delete managed memory
soap_free(soap); // free the context
See also
soap_malloc, soap_wstrdup, soap_unlink, soap_delegate_deletion, soap_destroy, soap_end.
Returns
copy of string or NULL when the specified string is NULL or on failure to allocate (out of memory)
Parameters
soap`soap` context
stringstring to copy to managed memory

◆ soap_unlink()

int soap_unlink ( struct soap soap,
const void *  ptr 
)

Unlink a block of heap memory managed by the specified soap context, to release the memory explicitly later.

This function removes a managed block of memory from the managing soap context. This memory is not released but rather should be released explicitly later by the application logic using free or delete. Returns #SOAP_OK when successful or #SOAP_ERR when the block is not managed by the specified context.

Returns
#SOAP_OK when successful or #SOAP_ERR when the block is not managed by the specified context
Parameters
soap`soap` context
ptrpointer to the block of managed heap memory to unlink

◆ soap_wstrdup()

wchar_t* soap_wstrdup ( struct soap soap,
const wchar_t *  string 
)

Copy a wide string to managed memory.

This function copies the specified wide string to managed memory. Returns a copy of the wide string or NULL when the specified wide string is NULL or when the function failed to allocate memory.

Example:
#include "soapH.h"
struct soap *soap = soap_new();
// allocate and assign a wide string in memory managed by the context
wchar_t *s = soap_wstrdup(soap, L"Hello");
... // send and receive messages etc.
soap_destroy(soap); // delete managed C++ objects
soap_end(soap); // delete managed memory
soap_free(soap); // free the context
See also
soap_malloc, soap_strdup, soap_unlink, soap_delegate_deletion, soap_destroy, soap_end.
Returns
copy of wide string or NULL when the specified wide string is NULL or on failure to allocate (out of memory)
Parameters
soap`soap` context
stringwide string to copy to managed memory or NULL
THREAD_ID
#define THREAD_ID
The thread ID of self.
Definition: stdsoap2.h:10125
soap_new
struct soap * soap_new()
Allocate and initialize a new soap context.
soap::accept_timeout
int accept_timeout
User-definable timeout when waiting to accept a request from a client at the server-side with soap_ac...
Definition: stdsoap2.h:3196
soap_free
void soap_free(struct soap *soap)
Finalize and free the given soap context from unmanaged heap memory.
soap_valid_socket
#define soap_valid_socket(sock)
Function macro to check if a socket is valid, i.e. not equal to #SOAP_INVALID_SOCKET
Definition: stdsoap2.h:1243
soap_force_closesock
int soap_force_closesock(struct soap *soap)
Forcibly close the socket connection.
soap_destroy
void soap_destroy(struct soap *soap)
Delete all dynamically-allocated C++ objects managed by the specified soap context.
soap::endpoint
char endpoint[SOAP_TAGLEN]
The endpoint string as received on the server side.
Definition: stdsoap2.h:3857
soap::recv_maxlength
ULONG64 recv_maxlength
User-definable maximum message length that is permitted to be received, zero means unlimited (the val...
Definition: stdsoap2.h:3080
soap_malloc
void * soap_malloc(struct soap *soap, size_t len)
Allocate a block of heap memory managed by the specified soap context.
soap_end
void soap_end(struct soap *soap)
Delete all data from heap memory managed by the specified soap context and release the freed memory b...
soap_serve
int soap_serve(struct soap *soap)
Serve a pending request.
soap_new1
struct soap * soap_new1(soap_mode input_and_output_mode)
Allocate and initialize a new soap context with input and output soap_mode flags.
soap::bind_flags
int bind_flags
User-definable setsockopt level SOL_SOCKET flags when binding soap::master socket (the value is 0 by ...
Definition: stdsoap2.h:3295
soap_closesock
int soap_closesock(struct soap *soap)
Close the socket connection.
soap
Context with the engine state.
Definition: stdsoap2.h:2742
soap::transfer_timeout
int transfer_timeout
User-definable timeout to send or receive an entire message, positive timeout values are seconds,...
Definition: stdsoap2.h:3094
soap_print_fault
void soap_print_fault(struct soap *soap, FILE *fd)
Print error message on the specified output.
soap_accept
SOAP_SOCKET soap_accept(struct soap *soap)
Accept a connection with a client.
THREAD_TYPE
#define THREAD_TYPE
Type of a thread (thread ID)
Definition: stdsoap2.h:10117
soap::send_timeout
int send_timeout
User-definable timeout to send a packet of data, positive timeout values are seconds,...
Definition: stdsoap2.h:3122
soap_init
void soap_init(struct soap *soap)
Initialize a stack-allocated soap context.
soap_init1
void soap_init1(struct soap *soap, soap_mode input_and_output_mode)
Initialize a stack-allocated soap context with input and output soap_mode flags.
THREAD_DETACH
#define THREAD_DETACH(tid)
Detach a thread.
Definition: stdsoap2.h:10193
soap_strdup
char * soap_strdup(struct soap *soap, const char *string)
Copy a string to managed memory.
soap_copy
struct soap * soap_copy(struct soap *soap)
Allocate and initialize a new soap context as a copy of the given soap context.
soap_copy_context
void soap_copy_context(struct soap *soap_destination, struct soap *soap_source)
Copy a given soap context to an uninitialized destination soap context.
SOAP_XML_INDENT
#define SOAP_XML_INDENT
soap_mode XML output flag value to enable XML (and JSON) message indentation in messages sent
Definition: stdsoap2.h:1784
soap_delegate_deletion
void soap_delegate_deletion(struct soap *soap, struct soap *soap_to)
Delegate the deletion of all managed objects and data from the specified soap context to another soap...
soap_done
void soap_done(struct soap *soap)
Finalize the given soap context, i.e. when the soap context is stack allocated, automatically invoked...
soap_wstrdup
wchar_t * soap_wstrdup(struct soap *soap, const wchar_t *string)
Copy a wide string to managed memory.
soap_bind
SOAP_SOCKET soap_bind(struct soap *soap, const char *host, int port, int backlog)
Bind and listen to a port.
THREAD_CREATE
#define THREAD_CREATE(tidptr, funcptr, argptr)
Create a new thread.
Definition: stdsoap2.h:10164