Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to write a client code for this webservice

Posted on 2012-04-02
7
Medium Priority
?
269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 36

Accepted Solution

by:
mccarl earned 2000 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 36

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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A solution for Fortify Path Manipulation.
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.
Suggested Courses

730 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