I have a question regarding to Ivan's notes on p.174.
It says "dynamic client, for which no artifacts have been generated".
But in the DynamicCalculatorClient class, I see AddNumbers and AddNumbersResponse are used.
These two classes AddNumbers and AddNumbersResponse are generated artifacts.
I don't see why Ivan says "dynamic client, for which no artifacts have been generated" ?
posted 6 years ago
According to Ivan, this is a dynamic client that does not require any generated artifacts. However in this code, AddNumbers is a generated artifact from Ivan' CalculatorService?wsdl.
Please help me to understand what a dynamic client mean? Thanks.
Although JAXB related classes do get generated while we use any java utility like wsimport (of JAX-WS) or wsdl2java (of Apache CXF framework), but this do not mean that we can not use JAXB without these other generated classes SEI, SIB etc.
Point is that when we use wsimport command, we get SEI, SIB, ObjectFactory, package-info and these auto generated JAXB classes. But we can always go ahead and creates JAXB artifacts by ourselves.
For any web service client, we need two things -
a. Details of SEI (at client side) to know about Port and Operation (web methods) details [ their input, output]
b. Way to convert XML Request and Response into Java classes (and vice-versa). These Java objects play role of input and output parameters in Web method invocation part.
So , for point a - we need auto generated SEI (and SIB) , for point b - , we need some Java framework to perform conversion - so here, we use JAXB framework (as mentioned in JAX-WS Specifications)
Allow me to mention about Static Clients. For Static clients, we generate client side artifacts with wsimport command which gives SEI, SIB and JAXB classes.So our point 'a' and 'b' are fulfilled. We just derive Port details from these SEI to invoke corresponding Web operations. All JAXb related conversion happens at backend (hidden from developer).
Our discussion focus is on Dynamic client .. as mentioned, dynamic client is web service client which do not use auto generated files SEI, SIB (from utility such as wsimport etc). All these SEI and SIB are generated at runtime based on WSDL file. So our point 'a' is fulfilled here by using Dispatch API. But for Java to XML Request/Response conversion, we still need JAVA framework like JAXB (to fulfill our point 'b' requirement).
JAXB is Java XML binding framework. Dynamic client interacts with Web Service Implementation through XML request and response. So as you know, with SOAP as protocol, we have SOAP Request and Response in XML format. To convert SOAP Request and Response to Java objects ( and vice-versa) , we use JAXB framework in Dynamic client.
Below mentioned is the code which explain usage of JAXB.
Here, I am trying to use Dispatch API with mode as PAYLOAD and transmission as Synchronous
we create MathService which add only have one operation add.