Seetha Rama Krishna wrote:
Hi,
i wanted to know how excatly the difference b/w calling a webservice using AXIS and SAAJ. Is there any extra features provided by SAAJ, apart from attachements.
Hi Seetha,
No, there aren't any extra features as such. It provides an alternative approach to call a web service (with or without attachments).

Actually this is how dev.java.net explains it.

"The SOAP with Attachments API for Java^TM (SAAJ) 1.3 provides the API for creating and sending SOAP messages by means of the |javax.xml.soap| package. It is used for the SOAP messaging that goes on behind the scenes in JAX-RPC, and JAXR implementations. SOAP Handlers in JAX-WS use SAAJ APIs to access the SOAP Message. Developers can also use it to write SOAP messaging applications directly instead of using JAX-RPC/JAX-WS." -
https://saaj.dev.java.net/source/browse/*checkout*/saaj/saaj-ri/docs/index.html

/sumedha

In SAAJ, we will call the webservice,like SOAPConnectionFactory connectionFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection connection = connectionFactory.createConnection();
    MessageFactory messageFactory = MessageFactory.newInstance();
    SOAPMessage message =messageFactory.createMessage();
    SOAPBody body =message.getSOAPBody();
      SOAPFactory factory = SOAPFactory.newInstance();
String endPointURL = "http://localhost:8081/axis/services/order";; SOAPMessage response =connection.call(message,endPointURL);
In Axis, we will call, like
GeneralItem gi = new GeneralItem();
  gi.setItem("snacks");
gi.setQuantity("4"); LiquitItem lt = new LiquitItem();
        lt.setQuantity("5");
        lt.setType("Hot Drinks");
        FoodItem fi = new FoodItem();
        fi.setLt(lt);
Item it = new Item();
  it.setFi(fi);
  it.setGi(gi);
com.items.Order or = new com.items.Order(); String endPointURL="http://localhost:8081/axis/services/order";; Service service = new Service();
  Call     call    = (Call) service.createCall();
  QName    qn      = new QName( "urn:Order", "order" );
call.registerTypeMapping(com.items.Order.class, qn, new org.apache.axis.encoding.ser.BeanSerializerFactory(com.items.Order.class, qn), new org.apache.axis.encoding.ser.BeanDeserializerFactory(com.items.Order.class, qn)); call.setTargetEndpointAddress( new java.net.URL(endPointURL) );
            call.setOperationName( new QName("Order", "processOrder") );
            call.addParameter( "arg1", qn, ParameterMode.IN );
call.setReturnType( org.apache.axis.encoding.XMLType.XSD_STRING );
            result =(String)call.invoke(new Object[] {it});
In the above axis code, we are passing the bean, where as using SAAJ, we are constructing the SOAP Request using SOAP API.
*/Martin Gainty <[EMAIL PROTECTED]>/* wrote:

    Didnt see anyone respond so i found this test harness from
    org.apache.axis2.saaj.SoapMessageTest.java
try {
                MessageFactory fac =
    MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
                //MessageFactory fac = MessageFactory.newInstance();
                SOAPMessage msg = fac.createMessage();
                SOAPPart soapPart = msg.getSOAPPart();
                SOAPEnvelope envelope = soapPart.getEnvelope();
                SOAPBody body = envelope.getBody();
AttachmentPart ap; //replace the fileName here with your attachment
                String fileName = System.getProperty("basedir", ".") +
    "/test-resources" + File.separator +"attach.xml";
InputStream inputStream = new FileInputStream(new
    File(fileName));
                ap = msg.createAttachmentPart(inputStream, "text/xml");
                DataHandler dh = new DataHandler(new
    SAAJDataSource(inputStream, 1000, "text/xml", true));
StringBuffer sb1 = copyToBuffer(dh.getInputStream());
                assertNotNull(ap);
//Verify attachment part is not empty and contents are
    correct
                try {
                    Object o = ap.getContent();
                    InputStream is = null;
                    assertNotNull(o);
                    if (o instanceof StreamSource)
                    {
                        StreamSource ss = (StreamSource)o;
                        is = ss.getInputStream();
                    }
                    else
                     {
                        fail("got object: " + o + ", expected object:
    javax.xml.transform.stream.StreamSource");
                    }
                }
                catch (Exception e)
                {
                    fail("attachment has no content - unexpected");
                }
            }
            catch (Exception e)
             {
                fail("Exception: " + e);
            }

    HTH
    Martin--

        ----- Original Message -----
        *From:* Seetha Rama Krishna <mailto:[EMAIL PROTECTED]>
        *To:* [email protected] <mailto:[email protected]>
        *Sent:* Saturday, March 15, 2008 1:06 AM
        *Subject:* RE: difference b/w bean mapping using SOAPBody

        Hi,
             Thanks for your reply.  My focus is to send a SOAP
        Request to the
        webservice,which is already exposed and get the response .
        That's it
        nothing more than that. No manipulation, nothing
What is bothering me is that whether i have to pass the bean
        class to AXIS / create the SOAP Request using  SAAJ.
                   One more thing is i need to send one attachment
        along with
        this SOAPRequest. So if i go for bean , how can i pass this
        attachement.

        */"Vinh Nguyen (vinguye2)" <[EMAIL PROTECTED]>/* wrote:

            Hi,
When you receive a SOAP response from a web service, the
            contents must match the WSDL/XSD schema defined for that
            service operation.  I believe what you want is to take
            that XML and send it back out in another slightly
            different format.  That amounts to changing from one
            schema to another, and I believe that's outside the scope
            of Axis2.
You might be able to write a simple translator framework
            that converts one XML to another using mappings between
            one property to another, but it might not be
            straightforward as that.
Keep in mind that Axis2 primaly handles sending/receiving
            SOAP.  It does comes with various data binding options
            built-in.  The actual data binding tool used (i.e.
            XmlBeans) mainly handles serialization between XML and the
            Java type for a given XSD schema.  To change from one
            schema to another, you'd have do write additional code for
            that.
-Vinh
            
------------------------------------------------------------------------
            *From:* Seetha Rama Krishna [mailto:[EMAIL PROTECTED]
            *Sent:* Friday, March 14, 2008 11:46 AM
            *To:* [email protected]
            *Subject:* difference b/w bean mapping using SOAPBody

            Hi,
                 I am new bie to AXIS.  I have to send a SOAP Request
            in the following format
            <general>
               <item>SOAP</item>
              <version>1.1</version>
            </general>
            <item>
              <foodItem>
                 <type>liquid</type>
                 <quantity>1</quantity>
               </fooditem>
             </item>
                     I had gone through SAAJ API and found that it is
            very easy to construct the  same SOAP Request.
                     My question is the same can be build using bean
            mapping concept in AXIS..
                       Is there any difference in sending the SOAP
            Request using AXIS with bean serialization an by using
            SAAJ API.
                Can any body suggest me how to proceed further
Thanks,
            ram
            
------------------------------------------------------------------------
            Chat on a cool, new interface. No download required. Click
            here.
            
<http://in.rd.yahoo.com/tagline_webmessenger_10/*http://in.messenger.yahoo.com/webmessengerpromo.php>





        Thanks & Regards,
        Krishna
        ------------------------------------------------------------------------
        Now you can chat without downloading messenger. Click here
        
<http://in.rd.yahoo.com/tagline_webmessenger_5/*http://in.messenger.yahoo.com/webmessengerpromo.php>
        to know how.




Thanks & Regards,
Krishna

------------------------------------------------------------------------
Bring your gang together - do your thing. Start your group. <http://in.rd.yahoo.com/tagline_groups_5/*http://in.promos.yahoo.com/groups>



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

Reply via email to