How can we implement WSSE plugin for 开发者_如何转开发Gsoap in C++/Linux ? This link doesn't give all the information.
The problem is what do I have to include in my header file generated by WSDL , to make it wsse compatible so that soapcpp2 header.h generates sufficient code so that I can compile wsseapi.c successfully ?
Also ,if possible please provide working sample code(C++ only , no C plz) which implements wsse plugin?
To automatically add an #import "wsse.h"
to the wsdl2h-generated header file if it is not already there (wsdl2h detects WS-Security requirements with WS-Policy), then first modify typemap.dat
to include these three lines:
[
#import "wsse.h"
]
Then (assuming C++):
- run
wsdl2h -Iimport -o service.h <your-wsdls-xsds-etc>
and make sure wsdl2h uses the modifiedtypemap.dat
(if it is in the current dir you are OK) and the import option points to the gsoapimport
directory withwsse.h
- run
soapcpp2 service.h
- compile the generated
soapC.cpp
,soapClient.cpp
(if client),soapServer.cpp
(if server),stdsoap2.cpp
,dom.cpp
,plugin/wsseapi.c
,plugin/smdevp.c
,plugin/mecevp.c
- when compiling the above, you must use
-DWITH_OPENSSL
-DWITH_DOM
- link against
-lssl
and-lcrypto
- to enable HTTP compression, compile with
-DWITH_GZIP
and link with-lz
When compiling in C, do all of the above but use wsdl2h option -c
and use the .c files.
See the WSSE documentation and also the gsoap/samples/wssedemo
example in the gsoap package, which shows the API calls to use WS-Security in several possible ways, tells you how to register the plugin etc.
what do I have to include in my header file
#import "wsse.h"
(See comments in the header file, or the generated documentation for part starting "Policy Enablers of Binding")
Update: Copy & Paste from generated documentation:
WS-Security (SOAP Message Security) 1.0 (accepts 1.1):
#import "wsse.h" // to be added to this header file for the soapcpp2 build step
#include "plugin/wsseapi.h"
soap_register_plugin(soap, soap_wsse); // register the wsse plugin in your code
// See the user guide gsoap/doc/wsse/html/index.html
(this can be found in generated doxygen documentation for your bindings)
See also how-to section.
精彩评论