Πέμπτη 7 Οκτωβρίου 2010

IBM WEBSPHERE STUDIO APPLICATION DEVELOPER AS A TOOL FOR WEB SERVICES DEVELOPMENT

IBM WEBSPHERE STUDIO APPLICATION DEVELOPER is an eclipse-based platform that can be used for easily building java-based web services. It offers wizard that can be used for transforming a java code into a web service. This wizard creates the WSDL file of the new web service. There is also one wizard that can be used to create a web service client. This wizard takes as input the WSDL file and creates four jsp pages that can be used as a simple web service client to test the web service.

Here is an example of a java code with four functions and its corresponding WSDL File created with the wizard Deploy as Web Service. This wizard can be found by right clicking on the java code file under the menu Web Services. Notice that is best to create a package to put your java code inside and use always lowecase on the first letter of your package name.

java code
File: elearn.GetFunctions.java

/*
 * Created on 10-Nov-09
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package elearn;

/**
 * @author mpouly
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
import java.util.Arrays;

public class GetFunctions {
   
   
    public int getParagontiko(int x1){
        int result=1;
        for(int i=2;i<=x1;i++){
            result = result*i;
        }
        return result;
    }
   
    public  String minmaxValues(int x1, int x2, int x3, int x4, int x5){
        int min=x1;
        int max=x1;
        int[] arrayint = {x1,x2,x3,x4,x5};
        for(int i=0; i<=4;i++){
            if(arrayint[i]<min){
                min = arrayint[i];
            }
            if(arrayint[i]>max){
                            max = arrayint[i];
                        }
        }
        return "The min value is " + String.valueOf(min) + " the max value is " + String.valueOf(max);
    }
   
    public  String bubbleSort(int x1, int x2, int x3, int x4, int x5){
            int[] arrayint = {x1,x2,x3,x4,x5};
        for (int pass=1; pass < 5; pass++) {
            for (int i=0; i < 5-pass; i++) {
                if(arrayint[i]>arrayint[i+1]){
                    int temp = arrayint[i];
                    arrayint[i] = arrayint[i+1];
                    arrayint[i+1] = temp;
                }
            }}
        String returnArray = "The sorted array is";
            for(int i=0; i<5; i++){
                returnArray = returnArray + String.valueOf(arrayint[i]) + ",";
            }
            return returnArray;
        }
   
   
    public  String sortArray(int[] x){
        Arrays.sort(x);
        String returnArray = "The sorted array is";
            for(int i=0; i<5; i++){
                returnArray = returnArray + String.valueOf(x[i]) + ",";
            }
            return returnArray;
    }
   
}

The WSDL file exported can be found under web content ->wsdl->elearn->GetFunctions.wsdl

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://elearn" xmlns:impl="http://elearn" xmlns:intf="http://elearn" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="http://elearn" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:impl="http://elearn" xmlns:intf="http://elearn" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <element name="getParagontiko">
    <complexType>
     <sequence>
      <element name="x1" type="xsd:int"/>
     </sequence>
    </complexType>
   </element>
   <element name="getParagontikoResponse">
    <complexType>
     <sequence>
      <element name="getParagontikoReturn" type="xsd:int"/>
     </sequence>
    </complexType>
   </element>
   <element name="bubbleSort">
    <complexType>
     <sequence>
      <element name="x1" type="xsd:int"/>
      <element name="x2" type="xsd:int"/>
      <element name="x3" type="xsd:int"/>
      <element name="x4" type="xsd:int"/>
      <element name="x5" type="xsd:int"/>
     </sequence>
    </complexType>
   </element>
   <element name="bubbleSortResponse">
    <complexType>
     <sequence>
      <element name="bubbleSortReturn" nillable="true" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>
   <element name="sortArray">
    <complexType>
     <sequence>
      <element maxOccurs="unbounded" minOccurs="0" name="x" type="xsd:int"/>
     </sequence>
    </complexType>
   </element>
   <element name="sortArrayResponse">
    <complexType>
     <sequence>
      <element name="sortArrayReturn" nillable="true" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>
   <element name="minmaxValues">
    <complexType>
     <sequence>
      <element name="x1" type="xsd:int"/>
      <element name="x2" type="xsd:int"/>
      <element name="x3" type="xsd:int"/>
      <element name="x4" type="xsd:int"/>
      <element name="x5" type="xsd:int"/>
     </sequence>
    </complexType>
   </element>
   <element name="minmaxValuesResponse">
    <complexType>
     <sequence>
      <element name="minmaxValuesReturn" nillable="true" type="xsd:string"/>
     </sequence>
    </complexType>
   </element>
  </schema>
 </wsdl:types>

   <wsdl:message name="bubbleSortResponse">

      <wsdl:part element="intf:bubbleSortResponse" name="parameters"/>

   </wsdl:message>

   <wsdl:message name="bubbleSortRequest">

      <wsdl:part element="intf:bubbleSort" name="parameters"/>

   </wsdl:message>

   <wsdl:message name="sortArrayResponse">

      <wsdl:part element="intf:sortArrayResponse" name="parameters"/>

   </wsdl:message>

   <wsdl:message name="sortArrayRequest">

      <wsdl:part element="intf:sortArray" name="parameters"/>

   </wsdl:message>

   <wsdl:message name="minmaxValuesResponse">

      <wsdl:part element="intf:minmaxValuesResponse" name="parameters"/>

   </wsdl:message>

   <wsdl:message name="getParagontikoResponse">

      <wsdl:part element="intf:getParagontikoResponse" name="parameters"/>

   </wsdl:message>

   <wsdl:message name="minmaxValuesRequest">

      <wsdl:part element="intf:minmaxValues" name="parameters"/>

   </wsdl:message>

   <wsdl:message name="getParagontikoRequest">

      <wsdl:part element="intf:getParagontiko" name="parameters"/>

   </wsdl:message>

   <wsdl:portType name="GetFunctions">

      <wsdl:operation name="getParagontiko">

         <wsdl:input message="intf:getParagontikoRequest" name="getParagontikoRequest"/>

         <wsdl:output message="intf:getParagontikoResponse" name="getParagontikoResponse"/>

      </wsdl:operation>

      <wsdl:operation name="bubbleSort">

         <wsdl:input message="intf:bubbleSortRequest" name="bubbleSortRequest"/>

         <wsdl:output message="intf:bubbleSortResponse" name="bubbleSortResponse"/>

      </wsdl:operation>

      <wsdl:operation name="sortArray">

         <wsdl:input message="intf:sortArrayRequest" name="sortArrayRequest"/>

         <wsdl:output message="intf:sortArrayResponse" name="sortArrayResponse"/>

      </wsdl:operation>

      <wsdl:operation name="minmaxValues">

         <wsdl:input message="intf:minmaxValuesRequest" name="minmaxValuesRequest"/>

         <wsdl:output message="intf:minmaxValuesResponse" name="minmaxValuesResponse"/>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="GetFunctionsSoapBinding" type="intf:GetFunctions">

      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="getParagontiko">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="getParagontikoRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="getParagontikoResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

      <wsdl:operation name="bubbleSort">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="bubbleSortRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="bubbleSortResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

      <wsdl:operation name="sortArray">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="sortArrayRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="sortArrayResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

      <wsdl:operation name="minmaxValues">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="minmaxValuesRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="minmaxValuesResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="GetFunctionsService">

      <wsdl:port binding="intf:GetFunctionsSoapBinding" name="GetFunctions">

         <wsdlsoap:address location="http://localhost:9080/elearning/services/GetFunctions"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

For test purposes the WSDL file can be tested by right clicking on hte file and selecting webservices->Test with web services explorer

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου