package com.javahonk;


import generated.webClient.stock.GetQuote;
import generated.webClient.stock.GetQuoteResponse;

import java.io.IOException;

import javax.xml.bind.JAXBElement;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support
				.ClassPathXmlApplicationContext;
import org.springframework.ws.client.core.WebServiceTemplate;


public class TestStockWebService {
	
	@Autowired
	private static WebServiceTemplate larsFeeTemplate;

	public static void main(String[] args) throws IOException {
		
		ClassPathXmlApplicationContext applicationContext = 
				new ClassPathXmlApplicationContext(
						"applicationContext.xml");
		
		WebServiceTemplate stockTemplate = (WebServiceTemplate)
				applicationContext.getBean("stockTemplate");
		
		
		GetQuote serviceRequest = new generated.webClient
				.stock.ObjectFactory().createGetQuote();
		serviceRequest.setSymbol("c");
		JAXBElement<GetQuoteResponse> responseObject =  
				(JAXBElement<GetQuoteResponse>) stockTemplate
				.marshalSendAndReceive(serviceRequest);
		
		System.out.println("Name: "+responseObject.getName()
				+" Value: "+responseObject.getValue());
		
		applicationContext.close();

	}

}
