⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 get_temp.cpp

📁 ESOAP是一款专注于嵌入式web service开发的工具 压缩包里提供了基本的例子
💻 CPP
字号:
/////////////////////////////////////////////////////////////////////////////
// $Id: get_temp.cpp,v 1.2 2001/09/18 13:34:41 rosimildo Exp $
//
// Copyright (c) 2001 Exor International Inc. All rights reserved.
//
// MODULE DESCRIPTION: A simple "get_temp" example for eSoap. It uses
//					   an Apache SOAP server described on Xmethods.
//
// MODIFICATION/HISTORY:
//
// $Log: get_temp.cpp,v $
// Revision 1.2  2001/09/18 13:34:41  rosimildo
// A few cleanups of the new examples: addtwo and get_temp
//
// Revision 1.1  2001/09/18 00:07:54  rosimildo
// Added two more examples: add_two  and get_temp.
//
//
// Created 2001/09/10 Rosimildo da Silva, ConnectTel Inc.
// [rdasilva@connecttel.com]
//
/////////////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include "TemperaturePortType_proxy.h"

#define ESOAP_SERVER_URL "http://services.xmethods.net/soap/servlet/rpcrouter"

void help()
{
  printf( "get temperarure from anywhere in US using ZipCode.\n" );
  printf( "See XMethods.org for details: www.xmethods.org\n" );
  printf( "Usage: get_temp <zipcode>\n" );
}

//
// uses the XMethods service to get the
// current temperature in a given U.S. zipcode region
// This is sample interface web services from XMethods. 
// The services are listed and described on:
// 
//        http://www.xmethods.com/
// 
//GetTemp: Weather Service
// =======================
// Service description URL: http://www.xmethods.com/detail.html?id=8
//
// Usage: get_temp <zipcode>
// 
//
int main(int argc, char *argv[])
{	
  if( argc < 2 )
  {
     help();
     exit( 2 );
  }
  esoap::String zipcode = argv[ 1 ];
  TemperatureService::TemperaturePortType_Proxy proxy( ESOAP_SERVER_URL, 30 );
  try
  {
     printf( "calling getTemp(  %s ) method.\n", zipcode.c_str() );
     float temp = proxy.getTemp( zipcode );
     printf( "Temperature for ZipCode: %s is: %.1f degrees Fahrenheit.\n",
              zipcode.c_str(),temp );
  }
  catch( esoap::SoapException & e )
  {
    printf( "SOAP Fault: Code=%s, String=%s\n", 
    		 e.getCode().c_str(), e.getString().c_str() );
  }
  catch( ... )
  {
    printf( "Weird C++ error. Please fix your code. :-)\n" );
  }
  // just to cleanup the memory...
  delete esoap::ParameterFactory::setInstance( 0 );
  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -