All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.capgemini.ntc.webapi.endpoint.soap.FarenheitToCelsiusMethod_Request_FromCode Maven / Gradle / Ivy

package com.capgemini.ntc.webapi.endpoint.soap;

import java.io.IOException;

import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.TransformerException;

import org.xml.sax.SAXException;

import com.capgemini.ntc.webapi.core.BasePageWebAPI;
import com.capgemini.ntc.webapi.soap.SoapMessageGenerator;
import com.jamesmurty.utils.XMLBuilder;

/**
 * SOAP endpoint for a SOAP web service that matches a request body with the following SOAP envelope:
 * 
 * 
 * 
 * 
 * 100
 * 
 * 
 * 
 **/
public class FarenheitToCelsiusMethod_Request_FromCode extends BasePageWebAPI {
	
	/*
	 * SOAP response built from Java code
	 */
	
	public FarenheitToCelsiusMethod_Request_FromCode() {
		setRoot("FahrenheitToCelsius");
	}
	
	/**
	 * @return Generate SOAP response in String format
	 */
	public String getMessage() {
		String message = "";
		try {
			SOAPMessage soapMessage = SoapMessageGenerator.createSOAPmessage(this.getRoot()
					.asString());
			message = SoapMessageGenerator.printSoapMessage(soapMessage);
		} catch (SOAPException | SAXException | IOException | ParserConfigurationException | TransformerException e) {
			new Exception(e);
		}
		return message;
	}
	
	/**
	 * @return Root XML structure
	 */
	public XMLBuilder getRoot() {
		return xmlBody;
	}
	
	// Set any type of "nodes" under xml Root
	/**
	 * Set "Fahrenheit" node under xml Root
	 * @param fahrenheit
	 * @return 
	 *         100
	 *         
	 */
	public FarenheitToCelsiusMethod_Request_FromCode setFahrenheit(int fahrenheit) {
		getRoot().element("Fahrenheit")
				.text(Integer.toString(fahrenheit));
		return this;
	}
	
	// Set any nodes under xml Root
	/**
	 * Set "Smth" node under xml Root
	 * @param fahrenheit
	 * @return 
	 *         Hello
	 *         
	 */
	public FarenheitToCelsiusMethod_Request_FromCode setSmth(String Smth) {
		getRoot().element("Smth")
				.text(Smth);
		return this;
	}
	
	/*
	 * ----------------------------------
	 * Any handy actions after this point
	 * ----------------------------------
	 */
	private XMLBuilder xmlBody;
	
	private void setRoot(String nodeName) {
		try {
			this.xmlBody = XMLBuilder.create(nodeName);
		} catch (ParserConfigurationException | FactoryConfigurationError e) {
			new Exception(e);
		}
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy