How to write a client code for this webservice

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
Ajoo71Asked:
Who is Participating?
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
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
 
Ajoo71Author Commented:
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
 
Ajoo71Author Commented:
Thanks, I guess I will have to close this thread
0
 
Ajoo71Author Commented:
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
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Why is my answer not suitable to be accepted? You made no comment as to why it isn't suitable.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.