||Struts 1.x 2.x | Spring | Strips | Wicket | Tapestry | Seam | JSF | RIFE | DWR | DOJO | EXT | Jquery | Json | Prototype | Hibernate | iBatis | web 2.0 | www.siva2baba.com & shivababa@gmail.com
   
  FrameWorks Theater
  Axis With SOAP Web Service
 
Apache Axis is an implementation of the SOAP

Axis is essentially a SOAP engine -- a framework for constructing SOAP processors such as clients, servers, gateways, etc. The current version of Axis is written in Java, but a C++ implementation of the client side of Axis is being developed.

*Simple Object Access Protocol”, but..
–Not really Simple
–Doesn’t really Access Objects
–Not really a Protocol


*What is it really?
–“A simple messaging framework for transferring information specified in the form of an XML infoset between an initial SOAP sender and an ultimate SOAP receiver” (SOAP 1.2 Primer)





SOAP is a lightweight protocol for exchanging structured information in a decentralized, distributed environment. It is an XML based protocol that consists of three parts: an envelope that defines a framework for describing what is in a message and how to process it, a set of encoding rules for expressing instances of application-defined datatypes, and a convention for representing remote procedure calls and responses.

SOAP is an XML-based communication protocol and encoding format for inter-application communication. Originally conceived by Microsoft and Userland software, it has evolved through several generations; the current spec is version, SOAP 1.2, though version 1.1 is more widespread. The W3C's XML Protocol working group is in charge of the specification.

SOAP is widely viewed as the backbone to a new generation of cross-platform cross-language distributed computing applications, termed Web Services.



Apache Axis has made developing Java Web services a breeze.  I will discuss some guidelines that prove to be very helpful when developing Java Web services using Axis.

This development customization of Axis and the deployment of Web services; it does not discuss the theory of Web services, XML, Java, and so forth.




  1. Customize WEB-INF/web.xml.
  2. Add the Axis libraries into the WEB-INF/lib folder.
  3. Create a server-config.wsdd file.
  4. Create Service Class


Axis-Sample
        ||--->web.xml
        ||--->server-config.wsdd
        ||-->+lib
        ||-->+classes
                        ||-->siva.java(service class)
                        ||-->soap.java(soap Request and Response)
siva.java
package com;
/**
 *
 * @author 150883
 */
public class siva {
   public siva(){}
   
    public String getsiva(String s){
       
        return "hello siva"+s;
    }
 }

soap.java
package com;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.LogHandler;
import org.apache.axis.utils.XMLUtils;

/**
 *
 * @author 150883
 */
public class soap extends LogHandler {
   
    public void invoke(MessageContext msg){
        try {

            Message request = msg.getRequestMessage();
            Message response = msg.getResponseMessage();
            Message message = null;

            if (response != null) {
                message = response;
                System.out.println("response");
            } else {
                message = request;
                System.out.println("request");
            }

            String soap = XMLUtils.ElementToString(message.getSOAPEnvelope());
            System.out.println("soap xml : "+soap);
        } catch (AxisFault ex) {
            Logger.getLogger(soap.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
   
}




Client  Program:Three type of client program generation(to invokeing web service)

       --->DII-(Dynamic Invo-Interface)
       --->Stub
       --->Proxy


Type 2-Stub

C:Documents and Settings150883>java org.apache.axis.wsdl.WSDL2Java  -p stub -o D:work   http://localhost:8080/Axis-Sample/services/siva?wsdl



Stub-program
      +-->
stub
                -->Siva.java
                -->SivaService.java
                -->SivaServiceLocator.java
                -->SivaSoapBindingStub.java
       +-->Client
                --->client.java


package Client;
import stub.*;
/**
 *
 * @author 150883
 */
public class Client
{
    public static void main(String[] args)throws Exception
    {
       
           
                SivaServiceLocator soc = new SivaServiceLocator();
                Siva port =soc.getsiva(new java.net.URL("http://localhost:8080/Axis-Sample/services/siva"));
                System.out.println("Client : "+port.getsiva("client"));
        }
}


           
Example program --http://siva2baba.diinoweb.com












What is RPC/Encoded?

Remote Procedure Call style invocation

Changes the Fault elements slightly
(WSDL 1.2) Each element in the “input” document is a parameter
Top-level structure MUST be a sequence (no “choice”)

SOAP Encoding

Serialization of XML adds ID and HREF to allow a directed graph (not just a tree)
Resulting XML document may no longer validate against the XML Schema










Document-Message


  - <wsdl:message name="getsivaRequest">
  <wsdl:part name="s" type="soapenc:string" />
  </wsdl:message>
- <wsdl:message name="getsivaResponse">
  <wsdl:part name="getsivaReturn" type="soapenc:string" />
  </wsdl:message>

RPC-message
  - <wsdl:message name="getsivaRequest">
  <wsdl:part element="tns1:s" name="s" />
  </wsdl:message>
- <wsdl:message name="getsivaResponse">
  <wsdl:part element="impl:getsivaReturn" name="getsivaReturn" />
  </wsdl:message>


Document-Port type
- <wsdl:portType name="siva">
- <wsdl:operation name="getsiva" parameterOrder="s">
  <wsdl:input message="impl:getsivaRequest" name="getsivaRequest" />
  <wsdl:output message="impl:getsivaResponse" name="getsivaResponse" />
  </wsdl:operation>
  </wsdl:portType>

RPC-port type
  - <wsdl:portType name="siva">
- <wsdl:operation name="getsiva" parameterOrder="s">
  <wsdl:input message="impl:getsivaRequest" name="getsivaRequest" />
  <wsdl:output message="impl:getsivaResponse" name="getsivaResponse" />
  </wsdl:operation>
  </wsdl:portType>


Document-Binding
  - <wsdl:binding name="sivaSoapBinding" type="impl:siva">
  <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="getsiva">
  <wsdlsoap:operation soapAction="" />
- <wsdl:input name="getsivaRequest">
  <wsdlsoap:body use="literal" />
  </wsdl:input>
- <wsdl:output name="getsivaResponse">
  <wsdlsoap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>

RPC-Binding
   <wsdl:binding name="sivaSoapBinding" type="impl:siva">
  <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="getsiva">
  <wsdlsoap:operation soapAction="" />
- <wsdl:input name="getsivaRequest">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://com" use="encoded" />
  </wsdl:input>
- <wsdl:output name="getsivaResponse">
  <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/Axis-Sample/services/siva" use="encoded" />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>




Document-Service
- <wsdl:service name="sivaService">
- <wsdl:port binding="impl:sivaSoapBinding" name="siva">
  <wsdlsoap:address location="http://localhost:8080/Axis-Sample/services/siva" />
  </wsdl:port>
  </wsdl:service>


RPC-service
  - <wsdl:service name="sivaService">
- <wsdl:port binding="impl:sivaSoapBinding" name="siva">
  <wsdlsoap:address location="http://localhost:8080/Axis-Sample/services/siva" />
  </wsdl:port>
  </wsdl:service>































 
  Today, there have been 2 visitors (9 hits) on this page! www.siva2baba.com & shivababa@gmail.com  
 
=> Do you also want a homepage for free? Then click here! <=
||Struts 1.x 2.x | Spring | Strips | Wicket | Tapestry | Seam | JSF | RIFE | DWR | DOJO | EXT | Jquery | Json | Prototype | Hibernate | iBatis | web 2.0 | http://siva2baba.diinoweb.com/files/ and www.siva2baba.com