package usecase.prosodie.deliveredService;

import javax.xml.namespace.QName;

import com.ebmwebsourcing.easybpel.model.bpel.api.BPELException;
import com.ebmwebsourcing.easybpel.model.bpel.api.message.BPELExternalMessage;
import com.ebmwebsourcing.easybpel.model.bpel.impl.message.BPELExternalMessageImpl;
import com.ebmwebsourcing.easyviper.core.api.CoreException;
import com.ebmwebsourcing.easyviper.environment.test.env.api.MockService;
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.impl.AbstractServiceImpl;
import com.ebmwebsourcing.easyviper.environment.test.env.impl.OperationImpl;

public class RefSDService extends AbstractServiceImpl implements MockService {

	public RefSDService(final ProviderEndpoint pep) throws BPELException {
		super(pep);
		this.setName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
				"DeliveredServiceService"));

		this.getClientOperations();
		this.saveClientOperation();
		this.removeClientOperation();
		this.removeDeliveredService();
		this.saveDeliveredService();
		this.getDeliveredServices();
	}

	private void getClientOperations() throws BPELException {
		System.out.println("getClientOperations");
		try {
			final Operation getDeliveredServices = new OperationImpl("getClientOperations",
					Operation.IN_OUT, this);
			this.addOperation(getDeliveredServices);

			final BPELExternalMessage in = new BPELExternalMessageImpl();
			in.setService(this.getName());
			in.setEndpoint(this.getProviderEndpoint().getName());
			in.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getClientOperationsRequest"));
			in
					.setMessage("<tns:getClientOperations xmlns:tns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\">"
							+ "<clientOperation xmlns:oc=\"http://document.prosodie.com/ClientOperation/1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"oc:ClientOperation\">"
							+ "<ns1:code xmlns:ns1=\"http://document.prosodie.com/ClientOperation/1/\">33333</ns1:code>"
							+ "</clientOperation>" + "</tns:getClientOperations>");

			final BPELExternalMessage out = new BPELExternalMessageImpl();
			out.setService(this.getName());
			out.setEndpoint(this.getProviderEndpoint().getName());
			out.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getDeliveredServicesResponse"));
			out
					.setMessage("<del:getClientOperationsResponse xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:del=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\" xmlns:ns=\"http://document.prosodie.com/ClientOperation/1/\" xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:ns2=\"http://document.prosodie.com/Sensitivity/1/\" xmlns:ns3=\"http://document.prosodie.com/Business/1/\" xmlns:ns4=\"http://document.prosodie.com/Resource/1/\">\r\n"
							+ "         <clientOperations>\r\n"
							+ "            <!--Zero or more repetitions:-->\r\n"
							+ "            <clientOperation>\r\n"
							+ "               <ns:code>33333</ns:code>\r\n"
							+ "            </clientOperation>\r\n"
							+ "         </clientOperations>\r\n"
							+ "      </del:getClientOperationsResponse>\r\n" + "");
			getDeliveredServices.addMessageExchangeInstances(in, out, null);

		} catch (final CoreException e) {
			throw new BPELException(e);
		}
		System.out.println("FIN getClientOperations");
	}

	private void saveClientOperation() throws BPELException {
		System.out.println("saveClientOperation");
		try {
			final Operation getDeliveredServices = new OperationImpl("saveClientOperation",
					Operation.IN_OUT, this);
			this.addOperation(getDeliveredServices);

			final BPELExternalMessage in = new BPELExternalMessageImpl();
			in.setService(this.getName());
			in.setEndpoint(this.getProviderEndpoint().getName());
			in.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"saveClientOperationRequest"));
			in
					.setMessage("<tns:saveClientOperation xmlns:tns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\">\r\n"
							+ "  <clientOperation xmlns:oc=\"http://document.prosodie.com/ClientOperation/1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"oc:ClientOperation\">\r\n"
							+ "    <ns1:code xmlns:ns1=\"http://document.prosodie.com/ClientOperation/1/\">2233</ns1:code>\r\n"
							+ "  </clientOperation>\r\n" + "</tns:saveClientOperation>");

			final BPELExternalMessage out = new BPELExternalMessageImpl();
			out.setService(this.getName());
			out.setEndpoint(this.getProviderEndpoint().getName());
			out.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"saveClientOperationResponse"));
			out
					.setMessage("<ns:saveClientOperationResponse xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\" xmlns:ns1=\"http://document.prosodie.com/ClientOperation/1/\" xmlns:ns2=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:ns3=\"http://document.prosodie.com/Sensitivity/1/\" xmlns:ns4=\"http://document.prosodie.com/Business/1/\" xmlns:ns5=\"http://document.prosodie.com/Resource/1/\" xmlns:ns6=\"http://document.prosodie.com/MainAffair/1/\" xmlns:ns7=\"http://document.prosodie.com/Client/1/\">\r\n"
							+ "         <clientOperation>\r\n"
							+ "            <ns1:code>2233</ns1:code>\r\n"
							+ "         </clientOperation>\r\n"
							+ "      </ns:saveClientOperationResponse>\r\n" + "");
			getDeliveredServices.addMessageExchangeInstances(in, out, null);

		} catch (final CoreException e) {
			throw new BPELException(e);
		}
		System.out.println("FIN saveClientOperation");
	}
	
	private void removeClientOperation() throws BPELException {
		System.out.println("removeClientOperation");
		try {
			final Operation getDeliveredServices = new OperationImpl("removeClientOperation",
					Operation.IN_OUT, this);
			this.addOperation(getDeliveredServices);

			final BPELExternalMessage in = new BPELExternalMessageImpl();
			in.setService(this.getName());
			in.setEndpoint(this.getProviderEndpoint().getName());
			in.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"removeClientOperationRequest"));
			in
					.setMessage("<tns:removeClientOperation xmlns:tns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\">\r\n" + 
							"  <clientOperation xmlns:oc=\"http://document.prosodie.com/ClientOperation/1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"oc:ClientOperation\">\r\n" + 
							"    <ns1:deliveredService xmlns:ns1=\"http://document.prosodie.com/ClientOperation/1/\">\r\n" + 
							"      <ns2:uuid xmlns:ns2=\"http://document.prosodie.com/DeliveredService/1/\">NNDDRRFG</ns2:uuid>\r\n" + 
							"    </ns1:deliveredService>\r\n" + 
							"    <ns1:code xmlns:ns1=\"http://document.prosodie.com/ClientOperation/1/\">4455</ns1:code>\r\n" + 
							"  </clientOperation>\r\n" + 
							"</tns:removeClientOperation>");

			final BPELExternalMessage out = new BPELExternalMessageImpl();
			out.setService(this.getName());
			out.setEndpoint(this.getProviderEndpoint().getName());
			out.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"removeClientOperationResponse"));
			out
					.setMessage("<removeClientOperationResponse/>");
			getDeliveredServices.addMessageExchangeInstances(in, out, null);

		} catch (final CoreException e) {
			throw new BPELException(e);
		}
		System.out.println("FIN removeClientOperation");
	}
	
	private void removeDeliveredService() throws BPELException {
		System.out.println("removeDeliveredService");
		try {
			final Operation getDeliveredServices = new OperationImpl("removeDeliveredService",
					Operation.IN_OUT, this);
			this.addOperation(getDeliveredServices);

			final BPELExternalMessage in = new BPELExternalMessageImpl();
			in.setService(this.getName());
			in.setEndpoint(this.getProviderEndpoint().getName());
			in.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"removeDeliveredServiceRequest"));
			in
					.setMessage("<tns:removeDeliveredService xmlns:tns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\">\r\n" + 
							"  <deliveredService xmlns:sd=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"sd:DeliveredService\">\r\n" + 
							"    <ns1:uuid xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\">SS-DD</ns1:uuid>\r\n" + 
							"  </deliveredService>\r\n" + 
							"</tns:removeDeliveredService>");

			final BPELExternalMessage out = new BPELExternalMessageImpl();
			out.setService(this.getName());
			out.setEndpoint(this.getProviderEndpoint().getName());
			out.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"removeDeliveredServiceResponse"));
			out
					.setMessage("<removeDeliveredServiceResponse/>" );
			getDeliveredServices.addMessageExchangeInstances(in, out, null);

		} catch (final CoreException e) {
			throw new BPELException(e);
		}
		System.out.println("FIN removeDeliveredService");
	}
	
	private void saveDeliveredService() throws BPELException {
		System.out.println("saveDeliveredService");
		try {
			final Operation getDeliveredServices = new OperationImpl("saveDeliveredService",
					Operation.IN_OUT, this);
			this.addOperation(getDeliveredServices);

			final BPELExternalMessage in = new BPELExternalMessageImpl();
			in.setService(this.getName());
			in.setEndpoint(this.getProviderEndpoint().getName());
			in.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"saveDeliveredServiceRequest"));
			in
					.setMessage("<tns:saveDeliveredService xmlns:tns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\">\r\n" + 
							"  <deliveredService xmlns:sd=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"sd:DeliveredService\">\r\n" + 
							"    <ns1:code xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\">556699</ns1:code>\r\n" + 
							"    <ns1:name xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\">TEST</ns1:name>\r\n" + 
							"    <ns1:enabled xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\">1</ns1:enabled>\r\n" + 
							"  </deliveredService>\r\n" + 
							"</tns:saveDeliveredService>");

			final BPELExternalMessage out = new BPELExternalMessageImpl();
			out.setService(this.getName());
			out.setEndpoint(this.getProviderEndpoint().getName());
			out.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"saveDeliveredServiceResponse"));
			out
					.setMessage("<ns:saveDeliveredServiceResponse xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\" xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:ns2=\"http://document.prosodie.com/Sensitivity/1/\" xmlns:ns3=\"http://document.prosodie.com/Business/1/\" xmlns:ns4=\"http://document.prosodie.com/Resource/1/\" xmlns:ns5=\"http://document.prosodie.com/MainAffair/1/\" xmlns:ns6=\"http://document.prosodie.com/Client/1/\">\r\n" + 
							"         <deliveredService>\r\n" + 
							"            <ns1:uuid>SN 12 36 54</ns1:uuid>\r\n" + 
							"            <ns1:code>556699</ns1:code>\r\n" + 
							"            <ns1:name>TEST</ns1:name>\r\n" + 
							"            <ns1:enabled>1</ns1:enabled>\r\n" + 
							"         </deliveredService>\r\n" + 
							"      </ns:saveDeliveredServiceResponse>\r\n" + 
							"");
			getDeliveredServices.addMessageExchangeInstances(in, out, null);

		} catch (final CoreException e) {
			throw new BPELException(e);
		}
		System.out.println("FIN saveDeliveredService");
	}
	
	private void getDeliveredServices() throws BPELException {
		System.out.println("getDeliveredServices");
		try {
			final Operation getDeliveredServices = new OperationImpl("getDeliveredServices",
					Operation.IN_OUT, this);
			this.addOperation(getDeliveredServices);

			final BPELExternalMessage in = new BPELExternalMessageImpl();
			in.setService(this.getName());
			in.setEndpoint(this.getProviderEndpoint().getName());
			in.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getDeliveredServicesRequest"));
			in
					.setMessage("<tns:getDeliveredServices xmlns:tns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\">\n" + 
							"  <deliveredService xmlns:sd=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"sd:DeliveredService\">\n" + 
							"    <ns1:mainAffair xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\">\n" + 
							"      <ns5:uuid xmlns:ns5=\"http://document.prosodie.com/MainAffair/1/\">AP1254</ns5:uuid>\n" + 
							"    </ns1:mainAffair>\n" + 
							"  </deliveredService>\n" + 
							"</tns:getDeliveredServices>");

			final BPELExternalMessage out = new BPELExternalMessageImpl();
			out.setService(this.getName());
			out.setEndpoint(this.getProviderEndpoint().getName());
			out.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getDeliveredServicesResponse"));
			out
					.setMessage("<ns:getDeliveredServicesResponse xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\" xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:ns2=\"http://document.prosodie.com/Sensitivity/1/\" xmlns:ns3=\"http://document.prosodie.com/Business/1/\" xmlns:ns4=\"http://document.prosodie.com/Resource/1/\" xmlns:ns5=\"http://document.prosodie.com/MainAffair/1/\" xmlns:ns6=\"http://document.prosodie.com/Client/1/\">\r\n" + 
							"         <deliveredServices>\r\n" + 
							"            <deliveredService>\r\n" + 
							"               <ns1:uuid>SN1</ns1:uuid>\r\n" + 
							"               <ns1:mainAffair>\r\n" + 
							"                  <ns5:uuid>AP1254</ns5:uuid>\r\n" + 
							"               </ns1:mainAffair>\r\n" + 
							"            </deliveredService>\r\n" + 
							"	    <deliveredService>\r\n" + 
							"               <ns1:uuid>SN2</ns1:uuid>\r\n" + 
							"               <ns1:mainAffair>\r\n" + 
							"                  <ns5:uuid>AP1254</ns5:uuid>\r\n" + 
							"               </ns1:mainAffair>\r\n" + 
							"            </deliveredService>\r\n" + 
							"         </deliveredServices>\r\n" + 
							"      </ns:getDeliveredServicesResponse>\r\n" + 
							"");
			getDeliveredServices.addMessageExchangeInstances(in, out, null);
			
			
			
			
			final BPELExternalMessage technicalException = new BPELExternalMessageImpl();
			technicalException.setService(this.getName());
			technicalException.setEndpoint(this.getProviderEndpoint().getName());
			technicalException.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getDeliveredServicesRequest"));
			technicalException
					.setMessage("<tns:getDeliveredServices xmlns:tns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\">\n" + 
							"  <deliveredService xmlns:sd=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"sd:DeliveredService\">\n" + 
							"    <ns1:mainAffair xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\">\n" + 
							"      <ns5:uuid xmlns:ns5=\"http://document.prosodie.com/MainAffair/1/\">AP7000</ns5:uuid>\n" + 
							"    </ns1:mainAffair>\n" + 
							"  </deliveredService>\n" + 
							"</tns:getDeliveredServices>");

			final BPELExternalMessage technicalFault = new BPELExternalMessageImpl();
			technicalFault.setService(this.getName());
			technicalFault.setEndpoint(this.getProviderEndpoint().getName());
			technicalFault.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getDeliveredServicesTechnicalFault"));
			technicalFault
					.setMessage("<soapenv:Fault xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\" xmlns:ns1=\"http://document.prosodie.com/Fault/1/\">\r\n" + 
							"      <faultcode>1</faultcode>\r\n" + 
							"      <faultstring xml:lang=\"fr\">test</faultstring>\r\n" + 
							"      <faultactor>Me</faultactor>\r\n" + 
							"      <detail>\r\n" + 
							"        <ns:getDeliveredServicesTechnicalFault>\r\n" + 
							"          <ns1:message>Pas bon</ns1:message>\r\n" + 
							"          <ns1:attributes>%3</ns1:attributes>\r\n" + 
							"        </ns:getDeliveredServicesTechnicalFault>\r\n" + 
							"      </detail>\r\n" + 
							"    </soapenv:Fault>\r\n" + 
							"");
			getDeliveredServices.addMessageExchangeInstances(technicalException, null, technicalFault);
			
			
			
			
			final BPELExternalMessage illegallException2 = new BPELExternalMessageImpl();
			illegallException2.setService(this.getName());
			illegallException2.setEndpoint(this.getProviderEndpoint().getName());
			illegallException2.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getDeliveredServicesRequest"));
			illegallException2
					.setMessage("<tns:getDeliveredServices xmlns:tns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\">\n" + 
							"  <deliveredService xmlns:sd=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"sd:DeliveredService\">\n" + 
							"    <ns1:mainAffair xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\">\n" + 
							"      <ns5:uuid xmlns:ns5=\"http://document.prosodie.com/MainAffair/1/\">AP6598</ns5:uuid>\n" + 
							"    </ns1:mainAffair>\n" + 
							"  </deliveredService>\n" + 
							"</tns:getDeliveredServices>");

			final BPELExternalMessage illegallFault = new BPELExternalMessageImpl();
			illegallFault.setService(this.getName());
			illegallFault.setEndpoint(this.getProviderEndpoint().getName());
			illegallFault.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getDeliveredServicesIllegalArgumentFault"));
			illegallFault
					.setMessage("<soapenv:Fault xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\" xmlns:ns1=\"http://document.prosodie.com/Fault/1/\">\r\n" + 
							"      <faultcode>1</faultcode>\r\n" + 
							"      <faultstring xml:lang=\"fr\">test</faultstring>\r\n" + 
							"      <faultactor>Me</faultactor>\r\n" + 
							"      <detail>\r\n" + 
							"        <ns:getDeliveredServicesIllegalArgumentFault>\r\n" + 
							"          <ns1:message>Pas bon</ns1:message>\r\n" + 
							"          <ns1:attributes>%3</ns1:attributes>\r\n" + 
							"        </ns:getDeliveredServicesIllegalArgumentFault>\r\n" + 
							"      </detail>\r\n" + 
							"    </soapenv:Fault>\r\n" + 
							"");
			getDeliveredServices.addMessageExchangeInstances(illegallException2, null, illegallFault);
			

			
			//Permet d'aller jusqu'a l'appel de l'aliasService et tester l'exeptions IllegalArgument de ce dernier
			final BPELExternalMessage in2 = new BPELExternalMessageImpl();
			in2.setService(this.getName());
			in2.setEndpoint(this.getProviderEndpoint().getName());
			in2.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getDeliveredServicesRequest"));
			in2
					.setMessage("<tns:getDeliveredServices xmlns:tns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\">\n" + 
							"  <deliveredService xmlns:sd=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"sd:DeliveredService\">\n" + 
							"    <ns1:mainAffair xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\">\n" + 
							"      <ns5:uuid xmlns:ns5=\"http://document.prosodie.com/MainAffair/1/\">AP9000</ns5:uuid>\n" + 
							"    </ns1:mainAffair>\n" + 
							"  </deliveredService>\n" + 
							"</tns:getDeliveredServices>");

			final BPELExternalMessage out2 = new BPELExternalMessageImpl();
			out2.setService(this.getName());
			out2.setEndpoint(this.getProviderEndpoint().getName());
			out2.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getDeliveredServicesResponse"));
			out2
					.setMessage("<ns:getDeliveredServicesResponse xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\" xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:ns2=\"http://document.prosodie.com/Sensitivity/1/\" xmlns:ns3=\"http://document.prosodie.com/Business/1/\" xmlns:ns4=\"http://document.prosodie.com/Resource/1/\" xmlns:ns5=\"http://document.prosodie.com/MainAffair/1/\" xmlns:ns6=\"http://document.prosodie.com/Client/1/\">\r\n" + 
							"         <deliveredServices>\r\n" + 
							"            <deliveredService>\r\n" + 
							"               <ns1:uuid>SN9</ns1:uuid>\r\n" + 
							"               <ns1:mainAffair>\r\n" + 
							"                  <ns5:uuid>AP9000</ns5:uuid>\r\n" + 
							"               </ns1:mainAffair>\r\n" + 
							"            </deliveredService>\r\n" + 
							"         </deliveredServices>\r\n" + 
							"      </ns:getDeliveredServicesResponse>\r\n" + 
							"");
			getDeliveredServices.addMessageExchangeInstances(in2, out2, null);
			
			
			//Permet d'aller jusqu'a l'appel de l'aliasService et tester l'exeptions TechnicalFault de ce dernier
			final BPELExternalMessage in3 = new BPELExternalMessageImpl();
			in3.setService(this.getName());
			in3.setEndpoint(this.getProviderEndpoint().getName());
			in3.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getDeliveredServicesRequest"));
			in3
					.setMessage("<tns:getDeliveredServices xmlns:tns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\">\n" + 
							"  <deliveredService xmlns:sd=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"sd:DeliveredService\">\n" + 
							"    <ns1:mainAffair xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\">\n" + 
							"      <ns5:uuid xmlns:ns5=\"http://document.prosodie.com/MainAffair/1/\">AP9001</ns5:uuid>\n" + 
							"    </ns1:mainAffair>\n" + 
							"  </deliveredService>\n" + 
							"</tns:getDeliveredServices>");

			final BPELExternalMessage out3 = new BPELExternalMessageImpl();
			out3.setService(this.getName());
			out3.setEndpoint(this.getProviderEndpoint().getName());
			out3.setQName(new QName("http://intranet-projet.prosodie/DeliveredServiceService/1/",
					"getDeliveredServicesResponse"));
			out3
					.setMessage("<ns:getDeliveredServicesResponse xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://intranet-projet.prosodie/DeliveredServiceService/1/\" xmlns:ns1=\"http://document.prosodie.com/DeliveredService/1/\" xmlns:ns2=\"http://document.prosodie.com/Sensitivity/1/\" xmlns:ns3=\"http://document.prosodie.com/Business/1/\" xmlns:ns4=\"http://document.prosodie.com/Resource/1/\" xmlns:ns5=\"http://document.prosodie.com/MainAffair/1/\" xmlns:ns6=\"http://document.prosodie.com/Client/1/\">\r\n" + 
							"         <deliveredServices>\r\n" + 
							"            <deliveredService>\r\n" + 
							"               <ns1:uuid>SN10</ns1:uuid>\r\n" + 
							"               <ns1:mainAffair>\r\n" + 
							"                  <ns5:uuid>AP9001</ns5:uuid>\r\n" + 
							"               </ns1:mainAffair>\r\n" + 
							"            </deliveredService>\r\n" + 
							"         </deliveredServices>\r\n" + 
							"      </ns:getDeliveredServicesResponse>\r\n" + 
							"");
			getDeliveredServices.addMessageExchangeInstances(in3, out3, null);
			
			
			
			
		} catch (final CoreException e) {
			throw new BPELException(e);
		}
		System.out.println("FIN getDeliveredServices");
		
		
			
	}

}
