Solved

How to write a client code for this webservice

Posted on 2012-04-02
7
265 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
XML extra information 8 35
Standalone trial or freeware to do SSL scan 4 52
Add to XML (Powershell) 1 41
How does proportional-column-width work in xsl fo 4 35
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
What You Need to Know when Searching for a Webhost Provider
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.

679 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