How to use/configure web services in any application ?

Hi everyone,

Anyone has any ideas about how to incorporate Web Services in any application? What all files one need to create and what all configurations one need to do for it. Can anyone put some light on this with some example ?

Thanks a lot in advance !

Replies

  • Manish Goyal
    Manish Goyal
    What kind of web services do you want in any application sookie???
  • sookie
    sookie
    goyal420
    What kind of web services do you want in any application sookie???
    Hey goyal420, thanks a lot for the reply. I already have some Web Service API ready and also have WSDL[Web Services Description Language]. I jus want to know what all steps one need to take for binding that wsdl in any application. I know one can call that Web services API method's in the application but what configurations one need to do for that.

    In other way, I want to know the entire flow of working of Webservices

    PS: Any kind of help will be appreciated in this regard . Thanks a lot !
  • Anil Jain
    Anil Jain
    If you are interested in binding part then do the following:

    WSDL – element
    - Tie the element to the protocol defined for the binding.
    - Define the transport protocol and style (RPC or Document).
    - For each operation of the each needs to be detailed.
    - For SOAP, the element needs to be defined, use (encoding or literal) and namespace.
    - If using encoding, needs to specifiy encodingStyle.

    Do let me know If you need anything specific.

    -CB
  • sookie
    sookie
    @crazyboy Thanks a lot that was really something informative response.

    One question, if I have that part of binding in my WSDL document then how can I call the methods[or to be more precise called as 'operations' in Web Services world] in my applications web pages ? Is it possible to do anything like that ?

    I am having two servers - First on which my current application runs[Can call it as Service Consumer] and Second is on which some other server is running providing some services [can be called as Service provider]. The Second server provides some services defined in a WSDL document. Now I want that WSDL to be found by First server [Service Consumer]

    Can you give some ideas about it ? Rest of the part I will do. I just need some ideas about all this working concept. 😕

    [EDIT]
    One more thing, Do I need to create any proxy and stub sort of classes to call that service in my application or is it possible without using them also ?

    Thanks a lot !
  • sookie
    sookie
    Hi everyone

    Thanks a lot for so much of your help. My problem is sort of solved. 😀

    We can consume web services in an application by using #-Link-Snipped-#. I am simplifying the steps and writing them down here

    STEP 1: Download separately[or can include them directly form Axis bin/lib folder if Axis is installed] and include following jar files in the CLASSPATH of your Client Class [Class which will consume services]
    • axis.jar
    • jaxrpc.jar
    • saaj.jar
    • commons-logging.jar
    • commons-discovery.jar
    • wsdl4j.jar
    [More jars may be required to add depending on the WSDL you might be using.]

    STEP 2: Download the WSDL file from Service Provider server's url For.eg. #-Link-Snipped-#
    Add File with extension as .wsdl in your project. Let me name above WSDL file as StockQuote.wsdl

    STEP 3: Now create stub classes using following command at run time. Go to appropriate structure of your project's folder and enter following command in Command prompt.

    java -classpath D:\bin\axis-1_4\lib\axis.jar;D:\bin\axis-1_4\lib\jaxrpc.jar;D:\bin\axis-1_4\lib\saaj.jar;D:\bin\axis-1_4\lib\commons-logging.jar;D:\bin\axis-1_4\lib\commons-discovery.jar;D:\bin\axis-1_4\lib\wsdl4j.jar; org.apache.axis.wsdl.WSDL2Java StockQuote.wsdl
    STEP 4: Now you can simply create Client class like following and use the operations specified in your WSDL. You can also pass paramters.

    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import javax.xml.namespace.QName;
       
    public class TestClient {
    public static void main(String [] args) {
    try {
        String endpoint ="https://www.webservicex.net/stockquote.asmx?WSDL";
               Service  service = new Service(); 
                Call     call    = (Call) service.createCall();
      
               call.setTargetEndpointAddress( new java.net.URL(endpoint) );
               call.setOperationName(new QName("https://soapinterop.org/", echoString"));
     
             String ret = (String) call.invoke( new Object[] { "Hello!" } );
      
             System.out.println("Sent 'Hello!', got '" + ret + "'");
           } catch (Exception e) {
             System.err.println(e.toString());
          }
        }
      }
    
    Finally, your work that you want to do using services is done. 😀

    For basic flow of Web services , check #-Link-Snipped-#

    PS: If any queries, Please ask- I may try to answer.
  • Manish Goyal
    Manish Goyal
    hey sookie can we consider this concept of web services similar to socket programming?I mean both are used for making connection and to retrieve the services..If i am right?If no can you please explain the difference?

You are reading an archived discussion.

Related Posts

Software piracy has been the biggest concern for top software makers, especially in countries such as India and China Windows 7 Home Premium can be bought for Rs.50. Read this...
new feature of Google search which is capable of recognizing when you are searching for a music artist, album or track, and can offer you direct links of the songs,...
Hello, I am not actually an engineer, but as prospective engineering student I thought that this would be a good place to get some advice on looking at different college...
Hello, if one is looking to go into software engineering, should he major in computer engineering, or computer science (assuming of course that the college they are looking at doesn't...
Sir / madam, My question is Find the missing number 16 [210] 14, 14 [156] 12, 12 [ ? ] 10 a. 110 b. 100 c. 120 d. 90 Advance...