~vcs-imports/simias/trunk

« back to all changes in this revision

Viewing changes to simias/tools/gsoap/gsoap-linux-2.7/plugin/httpgettest.c

  • Committer: kalidasbala
  • Date: 2007-08-25 12:48:51 UTC
  • Revision ID: vcs-imports@canonical.com-20070825124851-vlfvzun3732ld196
Latest gsoap code update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
httpgettest.c
 
4
 
 
5
gSOAP HTTP GET plugin example application.
 
6
 
 
7
gSOAP XML Web services tools
 
8
Copyright (C) 2000-2006, Robert van Engelen, Genivia, Inc., All Rights Reserved.
 
9
 
 
10
--------------------------------------------------------------------------------
 
11
gSOAP public license.
 
12
 
 
13
The contents of this file are subject to the gSOAP Public License Version 1.3
 
14
(the "License"); you may not use this file except in compliance with the
 
15
License. You may obtain a copy of the License at
 
16
http://www.cs.fsu.edu/~engelen/soaplicense.html
 
17
Software distributed under the License is distributed on an "AS IS" basis,
 
18
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
19
for the specific language governing rights and limitations under the License.
 
20
 
 
21
The Initial Developer of the Original Code is Robert A. van Engelen.
 
22
Copyright (C) 2000-2004, Robert van Engelen, Genivia, Inc., All Rights Reserved.
 
23
--------------------------------------------------------------------------------
 
24
GPL license.
 
25
 
 
26
This program is free software; you can redistribute it and/or modify it under
 
27
the terms of the GNU General Public License as published by the Free Software
 
28
Foundation; either version 2 of the License, or (at your option) any later
 
29
version.
 
30
 
 
31
This program is distributed in the hope that it will be useful, but WITHOUT ANY
 
32
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 
33
PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
34
 
 
35
You should have received a copy of the GNU General Public License along with
 
36
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
37
Place, Suite 330, Boston, MA 02111-1307 USA
 
38
 
 
39
Author contact information:
 
40
engelen@genivia.com / engelen@acm.org
 
41
--------------------------------------------------------------------------------
 
42
 
 
43
Compile:
 
44
 
 
45
soapcpp2 -CS -c httpgettest.h
 
46
cc -DWITH_NONAMESPACES -Iplugin -o httpgettest httpgettest.c soapC.c soapClient.c httpget.c stdsoap2.c
 
47
 
 
48
To support https and compression, compile with:
 
49
 
 
50
cc -DWITH_NONAMESPACES -DWITH_OPENSSL -DWITH_GZIP -Iplugin -o httpgettest httpgettest.c soapC.c httpget.c stdsoap2.c -lssl -lcrypto -lz
 
51
 
 
52
*/
 
53
 
 
54
#include "soapH.h"
 
55
#include "httpget.h"
 
56
 
 
57
int main(int argc, char **argv)
 
58
{ struct soap soap;
 
59
  if (argc < 2)
 
60
  { fprintf(stderr, "Usage: httpgettest URL\n");
 
61
    exit(0);
 
62
  }
 
63
  soap_init(&soap);
 
64
  soap_register_plugin(&soap, http_get); // register plugin
 
65
  if (soap_get_connect(&soap, argv[1], NULL)
 
66
   || soap_begin_recv(&soap))
 
67
  { soap_print_fault(&soap, stderr);
 
68
    exit(1);
 
69
  }
 
70
  if (soap.http_content)
 
71
    printf("Content type = %s\n", soap.http_content);
 
72
  printf("Content length = %ld\n", soap.length);
 
73
  if ((soap.mode & SOAP_IO) == SOAP_IO_CHUNK
 
74
#ifdef WITH_ZLIB
 
75
      || soap.zlib_in != SOAP_ZLIB_NONE
 
76
#endif
 
77
     )
 
78
  { soap_wchar c;
 
79
    // This loop handles chunked/compressed transfers
 
80
    for (;;)
 
81
    { if ((c = soap_getchar(&soap)) == (int)EOF)
 
82
        break;
 
83
      putchar((int)c);
 
84
    }
 
85
  }
 
86
  else
 
87
  { // This loop handles HTTP transfers (with HTTP content length set)
 
88
    if (soap.length)
 
89
    { size_t i;
 
90
      for (i = soap.length; i; i--)
 
91
      { soap_wchar c;
 
92
        if ((c = soap_getchar(&soap)) == (int)EOF)
 
93
        { soap.error = SOAP_EOF;
 
94
          break;
 
95
        }
 
96
        putchar((int)c);
 
97
      }
 
98
    }
 
99
  }
 
100
  soap_end_recv(&soap);
 
101
  soap_end(&soap);
 
102
  soap_done(&soap);
 
103
  return 0;
 
104
}
 
105
 
 
106
SOAP_NMAC struct Namespace namespaces[] =
 
107
{
 
108
        {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope", NULL},
 
109
        {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding", NULL},
 
110
        {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
 
111
        {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},
 
112
        {NULL, NULL, NULL, NULL}
 
113
};