Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic client and no generated artifacts?

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" ?

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dynamic means: you don't use the static generated artifacts.

However in this code, AddNumbers is a generated artifact from Ivan' CalculatorService?wsdl.

Yes, that is just to show you that the code works. He could have easily created the AddNumbers class by hand.

Regards,
Frits
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


Then we publish this MathService with URL as http://localhost:8848/mathService
For this web service to work, sample SOAP message are

SOAP Request - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:arit="http://arith/"><soapenv:Header/><soapenv:Body><arit:add><arg0>200</arg0><arg1>400</arg1></arit:add></soapenv:Body></soapenv:Envelope>

SOAP Response - <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Header/><S:Body><ns2:addResponse xmlns:ns2="http://arith/"><return>600</return></ns2:addResponse></S:Body></S:Envelope>

So I created Add.java and AddResponse.java file [ JAXB files] corresponding to these XMLs.






Now I create Dynamic client which uses these Add and AddResponse classes to perform conversion.



DynamicClient_With_JAXB_Type_Mode_PayLoad_Request.xml is



Output is

addRequest Object = Add [num1=98, num2=89]
Add Response = AddResponse [returnA=187]


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic