package com.ebmwebsourcing.easybpel.usecase.emptymessage;

import java.io.File;
import java.io.IOException;

import javax.xml.namespace.QName;

import org.jdom.JDOMException;

import com.ebmwebsourcing.easybpel.model.bpel.api.BPELException;
import com.ebmwebsourcing.easybpel.model.bpel.impl.message.BPELExternalMessageImpl;
import com.ebmwebsourcing.easyviper.core.api.CoreException;
import com.ebmwebsourcing.easyviper.environment.test.env.api.Operation;
import com.ebmwebsourcing.easyviper.environment.test.env.api.ProviderEndpoint;
import com.ebmwebsourcing.easyviper.environment.test.env.api.Service;
import com.ebmwebsourcing.easyviper.environment.test.env.impl.AbstractServiceImpl;
import com.ebmwebsourcing.easyviper.environment.test.util.MockServiceBuilder;

public class VersionEmptyService extends AbstractServiceImpl implements Service {


	public VersionEmptyService(ProviderEndpoint pep) throws BPELException, JDOMException, IOException {
		super(pep);
		//Service QName
		this.setName(new QName("http://axisversion.sample2", "Version"));

		// Create operation
		getVersion();
	}

	private void getVersion() throws BPELException, JDOMException, IOException {
		try {

			File fileIn1 = new File("./src/test/resources/messages/versionRequestEmptyPart.xml");
			File fileOut1 = new File("./src/test/resources/messages/versionResponseEmptyPart.xml");
			
			//new operation + client1
			Operation sendVersion = MockServiceBuilder.buildOperation(
					"getVersion",
					this,
					fileIn1,                                        //RequestXMLFile
					new QName("http://axisversion.sample2", "getVersionRequest"),         //RequestMessageName
					fileOut1,                                       //ResponseXMLFile
					new QName("http://axisversion.sample2", "getVersionRequestResponse"),           //ResponseMessageName
					null,
					null,
					BPELExternalMessageImpl.class);
					
			

			this.addOperation(sendVersion);
			
			

		} catch (CoreException e) {
			throw new BPELException(e);
		}
	}

}
