Showing posts with label web service. Show all posts
Showing posts with label web service. Show all posts

Tuesday, April 28, 2015

web service client JAXWS by maven

Generate web service client stub class by using the JAXWS maven plugin.

"jaxws-maven-plugin" will generate the web service stub classes by using that we can implement client or test the web service.


generated stub classes will stored under src folder and by using this service classes we can communicate with service and get the response.

for free webservice for the learning and client implementation visit xmethod.com

take any service and generate the client stub classes.


add the WSDL URL in the pom.xml

<wsdlUrls>
     <wsdlUrl>                            
    enter the wsdl URL here
     </wsdlUrl>
</wsdlUrls>


full sample :



Thursday, June 3, 2010

Coherenc samples and clustering with help of oracle coherence tutorials

All below explanation and samples are done by reading the document provided by the oracle coherence.

The simplest and most flexible way to create caches in Coherence is to use the cache configuration descriptor to define attributes and names for your application's or cluster's caches, and to instantiate the caches in your application code referring to them by name that matches the names or patterns as defined in the descriptor.

This approach to configuring and using Coherence caches has a number of very important benefits. It separates the cache initialization and access logic for the cache in your application from its attributes and characteristics. This way your code is written in a way that is independent of the cache type that will be utilized in your application deployment and changing the characteristics of each cache (such as cache type, cache eviction policy, and cache type-specific attributes, etc.) can be done without making any changes to the code whatsoever. It allows you to create multiple configurations for the same set of named caches and to instruct your application to use the appropriate configuration at deployment time by specifying the descriptor to use in the java command line when the node JVM is started.

DownLoad the latest oracle coherence from the below link
Download

Before configuring the cache will have understand the cache configuration

see the explore-config.xml file which will present in \examples\config\

coherence config will have two primary sections caching-schemessection and caching-scheme-mapping section.

sample:



The caching-schemessection is where the attributes of a cache or a set of caches get defined. The caching schemes can be of a number of types, each with its own set of attributes. The caching schemes can be defined completely from scratch, or can incorporate attributes of other existing caching schemes, referring to them by their scheme-names(using ascheme-ref element) and optionally overriding some of their attributes to create new caching schemes. This flexibility enables you to create caching scheme structures that are easy to maintain, foster reuse and are very flexible.

The caching-scheme-mapping section is where the specific cache name or a naming pattern is attached to the cache scheme that defines the cache configuration to use for the cache that matches the name or the naming pattern.

Now we will add the VirtualCache which is distributed cache






























.... need to update the more content after few days....

sample configuration and war file download from below code.
coherence_sample_download

Tuesday, March 23, 2010

Generate Webservice proxy classes or client stub classes by MAVEN

Add the following plugin and dependencies

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>axistools-maven-plugin</artifactId>
    <version>1.3</version>
    <configuration>
      <!-- <urls>
            <url>http://sample.webservice.com?wsdl
            </url>
        </urls> --> 
        <wsdlFiles>
            <wsdlFile>HelloService.wsdl</wsdlFile>
        </wsdlFiles> 
        <outputDirectory>/src/main/java</outputDirectory>
         <!-- <packageSpace>com.company.wsdl</packageSpace> --> 
        <testCases>true</testCases>
        <serverSide>true</serverSide>
        <subPackageByFileName>true</subPackageByFileName>
       
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Dependency :

            <dependency>
                <groupId>axis</groupId>
                <artifactId>axis</artifactId>
                <version>1.4.0</version>
                <!-- <properties>
                    <war.bundle>true</war.bundle>
                </properties> -->
            </dependency>
       
            <dependency>
                <groupId>axis</groupId>
                <artifactId>axis-jaxrpc</artifactId>
                <version>1.2-RC2</version>
                <!-- <properties>
                    <war.bundle>true</war.bundle>
                </properties> -->
            </dependency>
       
            <dependency>
                <groupId>axis</groupId>
                <artifactId>axis-wsdl4j</artifactId>
                <version>1.2-RC2</version>
            <!--<properties>
                    <war.bundle>true</war.bundle>
                </properties>-->
            </dependency>
       
            <dependency>
                <groupId>axis</groupId>
                <artifactId>axis-saaj</artifactId>
                <version>1.2-RC2</version>
                <!-- <properties>
                    <war.bundle>true</war.bundle>
                </properties> -->
            </dependency>
            <dependency> <groupId>xerces</groupId> <artifactId>xerces</artifactId>
                <version>2.4.0</version>
                <!--  <properties> <war.bundle>true</war.bundle>
                </properties> --> 
                </dependency>
            <dependency>
                <groupId>xerces</groupId>
                <artifactId>xercesImpl</artifactId>
                <version>2.4.0</version>
            <!--  <properties>
                    <war.bundle>true</war.bundle>
                </properties> -->
            </dependency>
           
            <dependency>
                <groupId>xml-apis</groupId>
                <artifactId>xml-apis</artifactId>
                <version>2.0.2</version>
                <!-- <properties>
                    <war.bundle>true</war.bundle>
                </properties> -->
            </dependency>
       
       
            <dependency>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
                <version>1.0.3</version>
                <!-- <properties>
                    <war.bundle>true</war.bundle>
                </properties> -->
            </dependency>
            <dependency>
                <groupId>commons-discovery</groupId>
                <artifactId>commons-discovery</artifactId>
                <version>0.2</version>
                <!-- <properties>
                    <war.bundle>true</war.bundle>
                </properties> -->
            </dependency>

Generate Webservice proxy classes or client stub classes by ANT

For ANT build :

 set the <taskdef> for axis-wsdl2java

<taskdef resource="axis-tasks.properties" classpathref="axis.classpath" />

 Axis taskdefs :

 axis-wsdl2java=org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask
 axis-java2wsdl=org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask

create target for the wsdl2java

  <target name="wsdl2java-client" description="task">
    
    <axis-wsdl2java 

    output="${generated.dir}"

    testcase="true"

    serverside="false"

    verbose="true"
   
    url="http://sample.webservice?wsdl" >

</axis-wsdl2java>
    
    </target>

 attachment of sample code with ant

Friday, March 19, 2010

Send and Receive files from remote system

Send and receive files from java socket programing

Sender :

1. Create a Scoket connection

ServerSocket servsock = new ServerSocket(13267);

2. Checks for the socket acceptence from socket client

Socket sock = servsock.accept();

3. Stream the file and output the stream


Receiver :

1. Create socket with sender ip address and port

Socket sock = new Socket("192.168.2.22",13267);

2. Get the stream from the socket .

InputStream is = sock.getInputStream();

 Source Code

WebServiceClient test code

Following is the sample test code to test the webservice

import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.namespace.QName;

public class TestClient {
  public static void main(String [] args) {
    try {
      String endpoint = "http://localhost:8080/axis/test.jws";
      Service  service = new Service();
      Call   call = (Call) service.createCall();
      call.setOperationName(new QName(endpoint, "addInt"));
      call.setTargetEndpointAddress( new java.net.URL(endpoint) );
      Integer ret = (Integer)call.invoke(new Object[]{new Integer(5), new Integer(6)});
      System.out.println("addInt(5, 6) = " + ret);
    } catch (Exception e) {
           System.err.println("Execution failed. Exception: " + e);
    }
  }
}

src attachment