• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Query regarding Dispatch.Invoke(T message) Method

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! Ivan,

This is related to the client communication model from your Guide.
I was trying invocation of service operation via Invoke() of Dispatch Interface in a synchronous manner.

QUERY

1. What i understood from the topic in the notes is that we must have JAXB generated classes with us before we execute this kind of client and we have to pass the package name of the generated classes to the JAXBContext("abc.def").Am i correct?
I think we can generate them with wsimport pretty easily.

2.Do we have some programming api , using which we can generate these JAXB classes.

3.When we can go for service operation invocation via PROXY mechanism which is far easier from programmer's perspective, why will some one go for this approach for Synchronous call.Can you please elaborate with some scenario so that we could understand it.


Thanks in Advance


Regards

Jolly
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
First, to you and others who are asking questions about my study notes, please refer to the section or page on which the example is - this makes it easier for me to find it. Thanks in advance!

Jolly Tiwari wrote:1. What i understood from the topic in the notes is that we must have JAXB generated classes with us before we execute this kind of client and we have to pass the package name of the generated classes to the JAXBContext("abc.def").Am i correct?


No, the client does not depend on using JAXB to create a request message. JAXB is just a convenient way to do it. You can also create SOAP messages using SAAJ, as can be seen on pages 203 and 204 in my study notes.


I think we can generate them with wsimport pretty easily.


Yes, JAXB bean classes can be generated with either wsimport or with the XJC JAXB schema compiler.


2.Do we have some programming api , using which we can generate these JAXB classes.


Not that I currently know of. You can, as I have shown in my study notes, use Ant scripts to run wsimport or XJC.


3.When we can go for service operation invocation via PROXY mechanism which is far easier from programmer's perspective, why will some one go for this approach for Synchronous call.Can you please elaborate with some scenario so that we could understand it.


If you do not have access to the WSDL of a service when writing your program.
Two possible cases:
Lets say you want to write a web service testing program, like soapUI. Then you cannot use the proxy mechanism because you do not know which web services you will need to send requests to, at the time of writing your program.
If you are writing a client of a web service that only sends XML messages, without using SOAP, then you cannot generate any proxies because there probably is no WSDL.
Best wishes!
 
Jolly Tiwari
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! Ivan,

Thanks for the explaination.

sorry for missing the referece point,It is

Sec 4.8 JAX-WS Client Communication model,Page 162
Well I have few doubts about this

Lets say you want to write a web service testing program, like soapUI. Then you cannot use the proxy mechanism because you do not know which web services you will need to send requests to, at the time of writing your program.



private Dispatch<Object> prepareCalculatorDispatch()
throws MalformedURLException, JAXBException
{
QName theName =new QName(SERVICE_NAMESPACE, SERVICE_PORT_NAME);
URL theWsdlUrl = new URL(WSDL_LOCATION);
QName theServiceName = new QName(SERVICE_NAMESPACE, SERVICE_NAME);
Service theService = Service.create(theWsdlUrl, theServiceName);
JAXBContext theJaxbContext =JAXBContext.newInstance("com.ivan.calculator");
Dispatch<Object> theDispatch =theService.createDispatch(theName, theJaxbContext,Service.Mode.PAYLOAD);

return theDispatch;
}



Fine if we take this scenario (When we don't know about the WSDL at the time of client Programming) then in order to get a Dispatch Object from Service Object we require at least below mentioned information from the user at the time of Web service client execution.These can be taken from some designed user interface and passed on to the client to web service as Strings.
a)SERVICE_NAMESPACE
b)SERVICE_PORT_NAME
c)WSDL_LOCATION
d)SERVICE_NAME

DOUBT:

When we don't know any thing about the target Web service at the time of writing of Web Service Client,then how will the JAXBContext reference be initialized.
I mean we don't have generated any JAXB wrapper classes and in fact we don't want our client to be tied to a specific set of JAXB generated classes

JAXBContext theJaxbContext =JAXBContext.newInstance("com.ivan.calculator");
Dispatch<Object> theDispatch =theService.createDispatch(theName, theJaxbContext,Service.Mode.PAYLOAD);



can you please elaborate how it will be taken care of?
I am unable to understand how this JAXBContext aspect will be catered.

Thanks in Advance

Regards

Jolly
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
If I do not know the WSDL or any XML schema at the time of programming, then I will not use JAXB.
Perhaps I will use SAAJ to construct SOAP messages, see example in section 5.7 of my study notes.
Best wishes!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic