WebSphere Web Services Client for C++, Version 1.0.1 운영 체제: Linux, Windows

myGetQuote 클라이언트 응용프로그램의 샘플 코드

myGetQuote 샘플은 WebSphere Application Server 주식 시세 샘플에서 나온 것입니다.

아래 표시된 myGetQuote 샘플은 WebSphere Application Server 주식 시세 셈플에서 나온 것이며 문서에서 다음과 같이 참조됩니다. “주식 시세 샘플은 SOAP(Simple Object Access Protocol)에서 XML 기반 RPC(JAX-RPC)용 Java API로 이주하는 주식 시세 클라이언트를 보여 줍니다. WebSphere는 JAX-RPC에서 클라이언트 프로그래밍 모델에 빌드하는 J2EE용 웹 서비스(JSR 109)를 지원합니다.”

다음 파일은 <inst_dir>/samples/getQuote에서 찾을 수 있습니다.

/*********************************************************************/
 /*                                                                   */
 /*                  IBM Web Services Client for C/C++                */
 /*                                                                   */
 /*  FILE NAME:      myGetQuote.cpp                                   */
 /*                                                                   */
 /*  DESCRIPTION:    main program to call the generated               */
 /*                  StockQuote stub                                  */
 /*                                                                   */
 /*********************************************************************/
 /*  <START_COPYRIGHT>                                                */
 /*                                                                   */
 /*  Licensed Materials - Property of IBM                             */
 /*                                                                   */
 /*  6205-001                                                         */
 /*                                                                   */
 /*  (c) Copyright IBM Corp. 2004, 2005                               */
 /*  All Rights Reserved                                              */
 /*                                                                   */
 /*  U.S. Government Users Restricted Rights - use,                   */
 /*  duplication or disclosure restricted by GSA                      */
 /*  ADP Schedule Contract with IBM Corp.                             */
 /*                                                                   */
 /*  Status: Version 1 Release 0                                      */
 /*  <END_COPYRIGHT>                                                  */
 /*                                                                   */
 /*********************************************************************/

// Include the WSDL2Ws generated StockQuote.hpp 
#include "StockQuote.hpp"

// Include the C++ header file that defines the function cout
#include <iostream>

int main()
{
	try
	{
		// Create a character string that contains the server endpoint URI for the
		// GetQuoteService web service.  Then pass the endpoint to the instantiator
		// for the GetQuote class that was generated by the WSDL2Ws tool.  The
		// endpoint will pointing to the location of service on Websphere Application
		// Server.
		char *  pszEndpoint = "http://<ServerName>:<PortNumber>/StockQuote/services/
urn:xmltoday-delayed-quotes";
		StockQuote * pwsStockQuote = new StockQuote( pszEndpoint);

		// If your network requires the use of a proxy, then add the following line of
		// code to configure AxisClient.
		/*
		char *  pszProxyURL = "<ProxyHost>";
		int     iProxyPortNumber = <ProxyPort>;

		pwsStockQuote->setProxy( pszProxyURL, iProxyPortNumber);
		*/

		// If you are using handlers, if the WSDL does not identify the SOAP action
		// then you will need to add your SOAP action before calling the web service.
		/*
		char *  pszHandlerName = "Handler";

		pwsStockQuote->setTransportProperty( SOAPACTIONHEADER , pszHandlerName);
		*/

		// Set the stock name to be quoted by the web service.  To test just the
		// web service, XXX is being used. This should return a stock quote of 55.25.  
		char *  pszStockName = "XXX";

		// Call the 'getQuote' method that is part of the StockQuote web service to
		// find the quoted stock price for the given company whose name is in
		// pszStockName.  The result of the quote search will be returned by this
		// method as a xsd__float type.
		xsd__float  fQuoteDollars = pwsStockQuote-> getQuote( pszStockName);

		// Output the quote.  If the stock name is unknown, then getQuote() will
		// return -1.  This name was recognized by the server and a constant value
		// is returned.

		if( fQuoteDollars != -1)
		{
			cout << "The stock quote for " << pszStockName << " is $" << fQuoteDollars
 << endl;
		}
		else
		{
			cout << "There is no stock quote for " << pszStockName << endl;
		}

		// Delete the web service.
		delete pwsStockQuote;
	}
	catch( SoapFaultException& sfe)
	{
		// Catch any other SOAP faults
		cout << "SoapFaultException: " << sfe.getFaultCode() << " " << sfe.what() 
<< endl;
	}
	catch( AxisException& e)
	{
		// Catch an AXIS exception
	cout << "AxisException: " << e.getExceptionCode() << " " << e.what() << endl;
	}
	catch( exception& e)
	{
		// Catch a general exception
	cout << "Unknown Exception: " << e.what() << endl;
	}
	catch( ...)
	{
		// Catch any other exception
	cout << "Unspecified Exception: " << endl;
	}

    // Exit.
    return 0;
}

Reference topic

이용약관 | 피드백

시간소인 아이콘마지막 갱신 날짜: 3 Mar 2006
http://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.websphere.wscc.doc.nl1\ref\wscc_rmygetquote.html

(C) Copyright IBM Corporation 2005. All Rights Reserved.
이 information Center는 Eclipse 기술을 기반으로 합니다. (http://www.eclipse.org)