IDENTITY AND ACCESS MANAGEMENT
[an error occurred while processing this directive]

Building a c webservice server

This may help you get a c webservice up and running.

  1. Use gSOAP.

    1. Make sure you always define -DWITH_OPENSSL in all builds.

  2. Start with a simple include file showing all the function you want to export, e.g.:

       struct TypeList {
        char* *types;
       };
    
    
       struct MemberQuery {
         char *id;     /* id of subject */
         char *grp;    /* group name */
         char *qid;    /* id of requestor (optional) */
       };
    
       int ns__gettypes( char *id, struct TypeList *types );
       int ns__ismember( struct MemberQuery *in, int *out );
    
        
  3. Process this with soapcpp2 to get the starter wsdl.

    1. I use the options: -c, -2

      "-c" to get c, rather than c++

      "-2" to get the more modern wsdl syntax.

  4. Edit the wsdl.

    1. You want to change default names to something that reflects your service.

    2. I have used, for example, this sed script

          s/http:\/\/localhost:80\/Service.wsdl/urn:washington.edu:eds.service/
          s/http:\/\/localhost:80/https:\/\/urizen.cac.washington.edu\/eds\/eds.wsdl/
          s/http:\/\/tempuri.org\/ns.xsd/urn:washington.edu:eds.service/g
          s/"ns:/"eds:/g
          s/xmlns:ns=/xmlns:eds=/g
          s/Service/EDSService/g
              

    3. Keep the converted wsdl and throw away all other generated files.

    4. Process the new wsdl with wsdl2h.

      1. I use the options: -c, -N, -n

        "-c" to get c, rather than c++

        "-N" and "-n" to get more meaningful routine names.

        For example: $ wsdl2h -c -Neds -neds eds.wsdl

    5. Process the generated include file with soapcpp2.

      1. I use the options: -c -2 -S -L -n -w -x -p

      2. (see the man page)

    6. Write the server program.

      1. See the documentation. I think standalone services are cleaner than cgis run behind apache. I also always use threads to handle calls.

      2. In your server you only have to import the 'nsmap' file. It will import others.

      3. I've also found it necessary to map the namespaces definition, possibly because of the soapcpp2 options. For example:

        #define eds_namespaces namespaces

      4. All the procedures you must provide, and their arguments, can be found in the *Stub.h file.

      5. gSOAP now builds two libraries: plain and ssl. Make sure you link the right one.


    [an error occurred while processing this directive]
    Jim Fox
    UW Technology
    Identity and Access Management
    University of Washington
    fox@washington.edu
    [an error occurred while processing this directive]
    [an error occurred while processing this directive]
[an error occurred while processing this directive]
Fox's Home

© 1983-2017, University of Washington