axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <mgai...@hotmail.com>
Subject RE: How to send attachments via local transport?
Date Fri, 08 Jun 2012 13:08:47 GMT

plenty of examples assume you have both TCPSender and TCPReceiver configured in conf/axis2.xml
  <transportReceiver name="tcp"  class="org.apache.axis2.transport.tcp.TCPServer">
        <parameter name="port">6060</parameter>
        <!--If you want to give your own host address for EPR generation-->
        <!--uncommet following paramter , and set as you required.-->
        <!--<parameter name="hostname">tcp://myApp.com/ws</parameter>-->
  </transportReceiver>  <transportSender name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
then assemble a quick test harness for your TCPSender and TCPServer (Receiver):
    //get the context
        org.apache.axis2.context.ConfigurationContext configContext=org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(Constants.TESTING_REPOSITORY,
Constants.TESTING_REPOSITORY + "/conf/axis2.xml");  //create the echo Operation
        org.apache.axis2.description.AxisOperation opdesc = new org.apache.axis2.description.OutInAxisOperation(new
javax.xml.namespace.QName("echoOMElement"));
        org.apache.axis2.client.Options options = new org.apache.axis2.client.Options();
        
        //set the endpoint
        org.apache.axis2.addressing.EndpointReference targetEPR =new org.apache.axis2.addressing.EndpointReference("tcp://127.0.0.1:5556"+
"/axis2/services/EchoXMLService/echoOMElement");
        options.setTo(targetEPR);
        options.setAction(operationName.getLocalPart());
        options.setTransportInProtocol("tcp");  //OMFactory to create OMNamespaces and OMElements
        org.apache.axiom.om.OMFactory fac = org.apache.axiom.om.OMAbstractFactory.getOMFactory();
       org.apache.axiom.om.OMNamespace omNs = fac.createOMNamespace("http://localhost/my",
"my");
        //assume any reference to <my:*>  will associate my elements with http://localhost/my
        //create the method
        org.apache.axiom.om.OMElement method = fac.createOMElement("echoOMElement", omNs);
        //create the value
        org.apache.axiom.om.OMElement value = fac.createOMElement("myValue", omNs);
        //set the value text
        value.setText("Isaac Asimov, The Foundation Trilogy");
        //right now references to echoOMElement so we need to add text of value to the method
echoOMElement ..notice the similar name as the echo Operation
        method.addChild(value);
        
        //SOAPFactory to get Envelope
        org.apache.axiom.soap.SOAPFactory factory = org.apache.axiom.om.OMAbstractFactory.getSOAP11Factory();
        
        //get the SOAP 1.1 envelope
        org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
        envelope.getBody().addChild(method);  //client needs a Message to send and receive
to awaiting service..lets create one here
        org.apache.axis2.context.MessageContext requestContext = new org.apache.axis2.context.MessageContext();
        //associate the params from existing configContext to our new MessageContext
        requestContext.setConfigurationContext(configContext);
        javax.xml.namespace.QName serviceName = new javax.xml.namespace.QName("EchoXMLService");
        javax.xml.namespace.QName operationName = new javax.xml.namespace.QName("echoOMElement");
        //create the AxisService
        org.apache.axis2.description.AxisService clientService= clientService = Utils.createSimpleServiceforClient(serviceName,
                                                           org.apache.axis2.engine.Echo.class.getName(),
                                                           operationName);
  //apprise the MessageObject what our new org.apache.axis2.description.AxisService is   
                                                   
        requestContext.setAxisService(clientService);
        org.apache.axis2.description.AxisOperation opdesc = new org.apache.axis2.description.OutInAxisOperation(new
javax.xml.namespace.QName("echoOMElement"));
        requestContext.setAxisOperation(opdesc);
        //apprise MessageObject what our SOAP 1.1. envelope is
        requestContext.setEnvelope(envelope);        org.apache.axis2.client.ServiceClient
sender = new org.apache.axis2.client.ServiceClient(configContext, clientService);
        //which options do we send
        sender.setOptions(options);
        org.apache.axis2.client.OperationClient opClient = sender.createClient(new javax.xml.namespace.QName("echoOMElement"));
        //which messageContext for sender client to transmit and receive
        opClient.addMessageContext(requestContext);
        opClient.setOptions(options);
        opClient.execute(true);  //get the MessageContext response
        org.apache.axis2.context.MessageContext response = opClient.getMessageContext("In");
        //get the response envelope
        org.apache.axiom.soap.SOAPEnvelope env = response.getEnvelope();
        assertNotNull(env);
         // The element in the body should be an OMSourcedElement
        org.apache.axiom.om.OMElement o = env.getBody().getFirstElement();
        System.out.println("returned OMElement text value="+o.getText();
        sender.cleanup();
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist
unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet
keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen
wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire
prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe
quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information
seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les
email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune
responsabilité pour le contenu fourni.

 Subject: How to send attachments via local transport?
Date: Fri, 8 Jun 2012 00:21:23 -0700
From: yrajaram@cisco.com
To: java-dev@axis.apache.org; java-user@axis.apache.org

Hi All: While using Local Transport we are finding that attachments are being passed on to
the receiving web service. However if we use regular HTTP invocation then the attachments
are passed on to the receiving web service. Wondering if anyone has successfully send attachments
via local transport – if so can you pls share a sample? Sincerely,YashwanthTechnical Architect,
EBIS  		 	   		  
Mime
View raw message