Solved

How to write a client code for this webservice

Posted on 2012-04-02
7
261 Views
Last Modified: 2012-05-12
HI Guys,

I generated stubs from this wsdl file StockQuoteService.wsdl (See a attached text WSDL file), I need to write client so that I can make a call to end point URL. I have created a mock service in the SOAP UI. http://localhost:8080/axis2/services/StockQuoteService. Can someone help me here to write client code. I have attached all stub java classes.

URL portAddress  = null;
            try {
                  
            portAddress = new URL("http://localhost:8080/axis2/services/StockQuoteService");
            
            System.out.println("Testing Webservice");
            StockQuoteServiceSOAP11BindingStub stub;
            StockQuoteServiceLocator stockServiceLocator = new StockQuoteServiceLocator();
            stub = stockServiceLocator.getStockQuoteServiceSOAP11port(portAddress)
            } catch (MalformedURLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }

Thanks in Advance
StockQuoteService.java
StockQuoteServiceLocator.java
StockQuoteServicePortType.java
StockQuoteServiceSOAP11BindingSt.java
StockQuoteServiceWSDL.txt
0
Comment
Question by:Ajoo71
  • 3
  • 2
7 Comments
 

Author Comment

by:Ajoo71
ID: 37796268
Ok, I got this working now, I have a question where do I use StockQuoteServiceSOAP11BindingStub stub class?

System.out.println("Testing Webservice");
StockQuoteServiceSOAP11BindingStub stub;
StockQuoteServiceLocator stockServiceLocator = new StockQuoteServiceLocator();
StockQuoteServicePortType portType = (StockQuoteServicePortType)stockServiceLocator.getStockQuoteServiceSOAP11port(portAddress);
double price = portType.getPrice("ABC");

System.out.println("Price is "+price);
0
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 37799066
You don't necessarily "need" to use the stub class, as such. Or more technically correct, you are already using the stub class, but you are just using it via the interface which is your port type.

In other words, the Service Locator is actually returning an object that is an instanceof the Stub class, however it returns it to you as a type corresponding to the Port Type interface. Or again another way of putting it, the Port Type is the interface that has all the remote service methods, ie. getPrice(), and the Stub is the actual implementation of that interface, that does the actual work of calling the web service when you call getPrice().
0
 

Author Comment

by:Ajoo71
ID: 37873994
Thanks, I guess I will have to close this thread
0
 

Author Comment

by:Ajoo71
ID: 37906744
I've requested that this question be closed as follows:

Accepted answer: 0 points for Ajoo71's comment #37873994

for the following reason:

Closing
0
 
LVL 35

Expert Comment

by:mccarl
ID: 37906745
Why is my answer not suitable to be accepted? You made no comment as to why it isn't suitable.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now