/*
* Copyright 2005-2009 WSO2, Inc. http://wso2.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
 
 
#include <stdio.h>
#include <ServiceClient.h>
#include <OMElement.h>
#include <iostream>
#include <AxisFault.h>
#include <Environment.h>

using namespace std;
using namespace wso2wsf;
 
int main(int argc, char *argv[])
{
	Environment::initialize("hello.log", AXIS2_LOG_LEVEL_TRACE);
	
	string end_point = "http://localhost:9090/axis2/services/hello";
 
	ServiceClient sc(end_point);
 
	OMElement * payload = new OMElement("greet");
	payload->setText("Hello World!");
	try
	{
		   OMElement* response = sc.request(payload, "");
			if (response)
			{
				cout << endl << "Response: " << response << endl;
			}
		}
		catch (AxisFault & e)
		{
			if (sc.getLastSOAPFault())
			{
				cout << endl << "Fault: " << sc.getLastSOAPFault() << endl;
			}
			else
			{
				cout << endl << "Error: " << e << endl;
			}
		}
		delete payload;
	}