You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.3 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /******************************************************************
  2. * $Id: simpleclient.c,v 1.12 2006/07/09 16:24:19 snowdrop Exp $
  3. *
  4. * CSOAP Project: CSOAP examples project
  5. * Copyright (C) 2003-2004 Ferhat Ayaz
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
  20. *
  21. * Email: ferhatayaz@yahoo.com
  22. ******************************************************************/
  23. #include <nanohttp/nanohttp-logging.h>
  24. #include <libcsoap/soap-client.h>
  25. static const char *url = "http://localhost:10000/csoapserver";
  26. static const char *urn = "urn:examples";
  27. static const char *method = "sayHello";
  28. int
  29. main(int argc, char *argv[])
  30. {
  31. SoapCtx *ctx, *ctx2;
  32. herror_t err;
  33. /* log_set_level(HLOG_VERBOSE); */
  34. err = soap_client_init_args(argc, argv);
  35. if (err != H_OK)
  36. {
  37. log_error4("%s():%s [%d]", herror_func(err), herror_message(err),
  38. herror_code(err));
  39. herror_release(err);
  40. return 1;
  41. }
  42. err = soap_ctx_new_with_method(urn, method, &ctx);
  43. if (err != H_OK)
  44. {
  45. log_error4("%s():%s [%d]", herror_func(err), herror_message(err),
  46. herror_code(err));
  47. herror_release(err);
  48. return 1;
  49. }
  50. soap_env_add_item(ctx->env, "xsd:string", "name", "Jonny B. Good");
  51. if (argc > 1)
  52. err = soap_client_invoke(ctx, &ctx2, argv[1], "");
  53. else
  54. err = soap_client_invoke(ctx, &ctx2, url, "");
  55. if (err != H_OK)
  56. {
  57. log_error4("[%d] %s(): %s ", herror_code(err), herror_func(err),
  58. herror_message(err));
  59. herror_release(err);
  60. soap_ctx_free(ctx);
  61. return 1;
  62. }
  63. soap_xml_doc_print(ctx2->env->root->doc);
  64. soap_ctx_free(ctx2);
  65. soap_ctx_free(ctx);
  66. soap_client_destroy();
  67. return 0;
  68. }