Solved

How to write a client code for this webservice

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse with Angularjs2.0 3 57
sql import cannot be resolved jsp 3 45
SequenceInputStream example 3 19
java imports not found 4 25
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
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…
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.

856 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