Loading ...
Sorry, an error occurred while loading the content.

Hello gSOAP help?

Expand Messages
  • gsoapacct
    From what I understand from the gSOAP documentation (4.2.1 Example)of http://www.cs.fsu.edu/~engelen/soapdoc.html#tth_sEc4.2 To create a web service I should
    Message 1 of 1 , Jun 6, 2002
    • 0 Attachment
      From what I understand from the gSOAP documentation (4.2.1 Example)of

      http://www.cs.fsu.edu/~engelen/soapdoc.html#tth_sEc4.2

      To create a web service I should "generate the skeletonroutines"
      So here's what I did:

      $ cat helloWorld.h
      class helloWorld {
      public:
      helloWorld ();
      helloWorld ( char *_msg );
      void print();
      private:
      char *msg;
      };

      $ /cygdrive/e/gSOAP/soapcpp-win32-2.1.3/soapcpp2.exe helloWorld.h

      ** The gSOAP Stub and Skeleton Compiler for C and C++ 2.1.3b
      ** Copyright (C) 2001-2002 Robert A. van Engelen, Florida State
      University
      ** This product is provided "as is", without any warranty

      Saving soapStub.h
      Saving soapH.h
      Saving soapC.cpp
      Saving soapClient.cpp
      Saving soapServer.cpp


      Compilation successful


      $ ls -l
      total 31
      -rw-r--r-- 1 someone None 286 Jun 4 14:49 helloWorld.cpp
      -rw-r--r-- 1 someone None 124 Jun 4 14:35 helloWorld.h
      -rw-r--r-- 1 someone None 20110 Jun 5 09:48 soapC.cpp
      -rw-r--r-- 1 someone None 251 Jun 5 09:48 soapClient.cpp
      -rw-r--r-- 1 someone None 4478 Jun 5 09:48 soapH.h
      -rw-r--r-- 1 someone None 578 Jun 5 09:48 soapServer.cpp
      -rw-r--r-- 1 someone None 1270 Jun 5 09:48 soapStub.h

      ... so far so good right?

      Now the question I have has to do with this part of
      the documentation.

      Here is an example Calculator service application that uses
      the
      generated soap_serve routine to handle client requests:

      // Contents of file "calc.cpp":
      #include "soapH.h"
      #include < math.h > // for sqrt()
      main()
      {
      soap_serve(); // use the remote method request dispatcher
      }
      // Implementation of the "add" remote method:
      int ns__add(double a, double b, double &result)
      {
      result = a + b;
      return SOAP_OK;
      }
      // Implementation of the "sub" remote method:
      int ns__sub(double a, double b, double &result)
      {
      result = a - b;
      return SOAP_OK;
      }
      // Implementation of the "sqrt" remote method:
      int ns__sqrt(double a, double &result);
      {
      if (a > = 0)
      {
      result = sqrt(a);
      return SOAP_OK;
      }
      else
      {
      soap_fault.faultstring = "Square root of negative
      number";
      soap_fault.detail = "I can only take the square root of
      a non-negative number";
      return SOAP_FAULT;
      }
      }
      // As always, a namespace mapping table is needed:
      struct Namespace namespaces[] =
      { // {"ns-prefix", "ns-name"}
      {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"},
      {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/"},
      {"xsi", "http://www.w3.org/1999/XMLSchema-instance"},
      {"xsd", "http://www.w3.org/1999/XMLSchema"},
      {"ns", "urn:simple-calc"}, // bind "ns" namespace prefix
      {NULL, NULL}
      };


      My helloWord.cpp looks like this ...

      $ cat helloWorld.cpp
      #include <stdio.h>
      #include "helloWorld.h"

      helloWorld::helloWorld () { msg = "Hello World"; }
      helloWorld::helloWorld ( char* _msg ) { msg = _msg; }
      void helloWorld::print() { printf ( "%s\n", msg); }

      $
      ... and I wrote a very simple test for this very simple class called
      main.cpp

      $ cat main.cpp
      #include "helloWorld.h"

      void main() {
      helloWorld hw;
      hw.print();
      }

      ... here's my question(s). Which file helloWorld.cpp or main.cpp do
      I add the ...

      #include "soapH.h"
      #include < math.h > // for sqrt()
      main()
      {
      soap_serve(); // use the remote method request dispatcher
      }
      .
      .
      .
      // As always, a namespace mapping table is needed:
      struct Namespace namespaces[] =
      { // {"ns-prefix", "ns-name"}
      {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"},
      {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/"},
      {"xsi", "http://www.w3.org/1999/XMLSchema-instance"},
      {"xsd", "http://www.w3.org/1999/XMLSchema"},
      {"ns", "urn:simple-calc"}, // bind "ns" namespace prefix
      {NULL, NULL}
      };

      ... code to? And how do I call the print() method since I do not see
      its prototype in the soapH.h file?

      I asked this one gSOAP yahoo group but nobody has answered.
    Your message has been successfully submitted and would be delivered to recipients shortly.