This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAX-WS Web Service Clients- Dynamic Clients Query

 
prashant k. gupta
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I was trying the example of Ivan’s study notes for SCDJWS (4.9 JAX-WS Web Service Clients). In this while trying dynamic Clients example I found that I have to import other classes which was not in example and also I had to import generated artifacts class, below is the import statements of my DynamicCalculatorClient:-

package com.ivan.dynamic;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.Future;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
import javax.xml.ws.AsyncHandler;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Response;
import javax.xml.ws.Service;


import com.ivan.calculator.AddNumbers;
import com.ivan.calculator.AddNumbersResponse;
import com.ivan.calculator.ObjectFactory;
import com.ivan.calculator.PrintNumber;

I used RAD7 for this example and my CalculatorService was already deployed on server and running and I generated the webservice client artifacts using WSDL and I had to import in my DynamicCalculatorClient class to suppress the compilations error. After that I was able to run the all examples using main methods:-

DynamicCalculatorClient theClient = new DynamicCalculatorClient();
theClient.callOnewayService();
theClient.callSyncReqRespService();
theClient.callAsyncReqRespService();
theClient.callAsyncHandlerReqRespService();


Is this the correct behavior since I saw in notes that’s its written generated artifacts does not required?


 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Your questions is well motivated - the section which you refer to is not entirely clear which generated artifacts are not needed.
In the example, JAXB bean classes, generated using the XJC JAXB schema compiler are used in order to create request payloads and parse response payloads.
The artifacts that are not needed are the JAX-WS service class and endpoint interface.
Instead of using JAXB, the example could have used a Dispatch<Source> object to send requests. A source can be one of DOMSource, SAXSource, StAXSource, StreamSource (and JAXBSource, but that is JAXB) from which XML data representing a request is read.
That you need to add import statements in your source code is correct - there were omitted in some of the examples to conserve space.
Hope things are more clear.
Best wishes!
 
prashant k. gupta
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ivan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic