Hi Chamikara,

I use tomcat in the server side and its version is the apache-tomcat-5.5.15.
I join in attachment my client code.

Thanks for your help.

Regards

Elodie



Chamikara Jayalath wrote:

Hi Elodie,

Are you using tomcat in the server side. If so which version?
Can u send your client code as well.

Chamikara


On 7/13/06, *Mancinelli Elodie* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Hi all,

    I want to realise an client-server which supports MTOM and WSRM. I
    created separatly a client-server with MTOM and a client-server
    with WSRM.

    My server has two methods: OneWay and RequestResponse.

    - When I launch my client to test the RequestResponse method:
    In TCPMon, I see, the CreateSequence and the
    CreateSequenceResponse. My
    first message is sent and it is accpeted.
    But my client never receives the response and there is no trace on my
    server, the method seems not be executed.

    - When I launch my client to test the OneWay method:
    In TCPMon, I see:
    - CreateSequence, CreateSequenceResponse
    - Three messages have send and three acknowledgments
    But no TerminateSequence.
    And on the server, there is an error:
    - "Servlet.service()" pour la servlet AxisServlet a généré une
    exception
    java.lang.IllegalStateException: Impossible de créer une sessionaprès
    que la réponse ait été envoyée
            at
    org.apache.catalina.connector.Request.doGetSession(Request.java:2214)
            at
    org.apache.catalina.connector.Request.getSession(Request.java:2024)
            at
    
org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:831)
            at
    
org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:842)
            at
    
org.apache.axis2.transport.http.AxisServlet.createAndSetInitialParamsToMsgCtxt
    (AxisServlet.java:81)
            at
    org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:131)
            at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
            at javax.servlet.http.HttpServlet.service
    (HttpServlet.java:802)
            at
    
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at
    
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java
    :173)
            at
    
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at
    
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at
    
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at
    
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at
    org.apache.catalina.core.StandardEngineValve.invoke
    (StandardEngineValve.java:107)
            at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
            at
    
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
            at
    
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            at
    
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
            at
    
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
            at java.lang.Thread.run(Thread.java:595)

    I have no informations in catalina logs.
    In precedent mails, somebody advise me to change the value of
    InOrderInvoker in the module.xml, but when I change this,
    client-server
    with MTOM only and client-server with WSRM only don't works.
    I have download the sandesha2-SNAPSHOT.mar
    (http://people.apache.org/repository/sandesha2/mars/
    <http://people.apache.org/repository/sandesha2/mars/>)

    Someone have an idea?

    Thanks a lot

    Elodie






    ---------------------------------------------------------------------
    To unsubscribe, e-mail: [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>
    For additional commands, e-mail: [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>



package fr.gouv.finances.dgme.presto;

import java.io.File;
import java.io.FileInputStream;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.client.async.AsyncResult;
import org.apache.axis2.client.async.Callback;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.MessageContextConstants;
import org.apache.sandesha2.client.SandeshaClientConstants;


public class PrestoWSRM_MTOMtest extends junit.framework.TestCase{

	static String fileXMLName="test_data_in.xml";
	static String fileNameAttach="fichier.txt";
	private static EndpointReference targetEPR = new EndpointReference("http://localhost:8080/axis2/services/PrestoSvc";);
	private static String targetEPRTcpmon ="http://localhost:8070/axis2/services/PrestoSvc";;
	static String namespace="http://dgme.finances.gouv.fr/presto";;
	private static String CLIENT_REPO_PATH = "RepoClient";
	private static String axis2_xml = CLIENT_REPO_PATH + File.separator +"conf" + File.separator + "axis2.xml";

	/**
	 * Call submitRequestReponse with attachment
	 *
	 */
	public  void testSubmitRequestResponseWSRMAddressable() throws Exception{

		String nameMethod="submit";
		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,axis2_xml);
		ServiceClient serviceClient = new ServiceClient (configContext,null);

		Options options=initOptions("submit",true);
		serviceClient.setOptions(options);
		String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
		options.setProperty(SandeshaClientConstants.AcksTo,acksTo);

		System.out.println("Envoi");
		Callback callback1 = new TestCallback ("Callback 1");
		serviceClient.sendReceiveNonBlocking (getOMBlock("message1","sequence1",nameMethod),callback1);

		while (!callback1.isComplete()) {
			System.out.println("boucle1");
			Thread.sleep(1000);
		}

		Callback callback2 = new TestCallback ("Callback 2");
		serviceClient.sendReceiveNonBlocking(getOMBlock("message2","sequence1",nameMethod),callback2);

		while (!callback2.isComplete()) {
			System.out.println("boucle2");
			Thread.sleep(1000);
		}

		options.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
		Callback callback3 = new TestCallback ("Callback 3");
		serviceClient.sendReceiveNonBlocking(getOMBlock("message3","sequence1",nameMethod),callback3);

		while (!callback3.isComplete()) {
			System.out.println("boucle3");
			Thread.sleep(1000);
		}
		System.out.println("Fin du programme");
		Thread.sleep(10000);
		serviceClient.finalizeInvoke();

	}

	
	/**
	 * Call submitOneWay with attachment
	 *
	 */
	public  void testSubmitOneWayWSRMEmetteurAnonyme() throws Exception {

		String nameMethod="submitOneWay";
		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,axis2_xml);
		ServiceClient sender = new ServiceClient (configContext,null);

		Options options=initOptions("submitOneWay", false);
		sender.setOptions(options);

		System.out.println("Envoi");

		sender.fireAndForget(getOMBlock("","ping1",nameMethod));
		sender.fireAndForget(getOMBlock("","ping2",nameMethod));

		options.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
		sender.fireAndForget(getOMBlock("","ping3",nameMethod));

		Thread.sleep(10000);
		System.out.println("\nResult :");
		System.out.println("NO RETURN FOR WEBSERVICE");
		sender.finalizeInvoke();

	}

	private OMElement getOMBlock(String text, String sequenceKey, String nameMethod) throws Exception{

		OMFactory fac = OMAbstractFactory.getOMFactory();
		OMNamespace omNs = fac.createOMNamespace(namespace, "m");
		OMElement payload = getPayload(nameMethod);

		// Attach text file
       		OMElement filetxt=createAttachment(fac,omNs);
       		payload.addChild(filetxt);

		// Add sequence number
//		OMElement sequenceElem = fac.createOMElement("Sequence",omNs);
//		if (nameMethod.equalsIgnoreCase("submit")) sequenceElem.setText(sequenceKey + "-" + text);
//		else sequenceElem.setText(sequenceKey);
//		payload.addChild(sequenceElem);

		System.out.println("Document sent : "+payload);

		return payload;

	}


	static class TestCallback extends Callback {

		String name = null;
		public TestCallback (String name) {
			this.name = name;
		}

		public void onComplete(AsyncResult result) {
//			Traitement du résultat et affichage
			System.out.println("\nResult :");
			System.out.println("Callback '" + name +  "' got result:" + result.getResponseEnvelope());
		}

		public void onError (Exception e) {
			System.out.println("Error reported for test call back");
			e.printStackTrace();
		}
	}

	/**
	 * Define options
	 *
	 */
	private static Options initOptions(String nameMethod,boolean SeparateListener){

		Options options = new Options ();
		options.setTo(targetEPR);
		options.setAction(nameMethod);
		options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
		options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
		options.setUseSeparateListener(SeparateListener);
		options.setProperty(MessageContextConstants.TRANSPORT_URL,targetEPRTcpmon);
		options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);

		return options;
	}

	/**
	 * Get file
	 *
	 */
	private OMElement getPayload(String operation) throws Exception {
		OMFactory fac = OMAbstractFactory.getOMFactory();
		// Declaration du namespace
		OMNamespace omNs = fac.createOMNamespace("http://dgme.finances.gouv.fr/presto";, "m");
		// Creation du sommet de l'arborescence
		OMElement payload = fac.createOMElement(operation, omNs);

		// Lecture du fichier a recuperer
		XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream("test_data_in.xml"));
		// Construction de l'element
		StAXOMBuilder builder = new StAXOMBuilder(fac, parser);
		// Intergration dans l arborescence
		payload.addChild(builder.getDocumentElement());

		return payload;
	}

	/**
	 * Method which create attachment
	 *
	 */
	private static OMElement createAttachment(OMFactory fac, OMNamespace omNs) throws Exception{

		OMElement attach = null;

		// Creation du noeud
		attach = fac.createOMElement("attachment", omNs);
		// Lecteure de ce fichier
		File fileTxt = new File(fileNameAttach);
		FileDataSource dataSource = new FileDataSource(fileTxt);
		// Transformation en données binaires
		DataHandler expectedDH = new DataHandler(dataSource);
		OMText textData = fac.createOMText(expectedDH, true);
		// Ajout au message soap
		attach.addChild(textData);

		return attach;
	}

}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to