aspose file tools*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Query regarding Dispatch.Invoke(T message) Method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Query regarding Dispatch.Invoke(T message) Method" Watch "Query regarding Dispatch.Invoke(T message) Method" New topic
Author

Query regarding Dispatch.Invoke(T message) Method

Jolly Tiwari
Ranch Hand

Joined: Mar 26, 2006
Posts: 77
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
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
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!


My free books and tutorials: http://www.slideshare.net/krizsan
Jolly Tiwari
Ranch Hand

Joined: Mar 26, 2006
Posts: 77
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

Joined: Oct 04, 2006
Posts: 2198
    
    1
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query regarding Dispatch.Invoke(T message) Method
 
Similar Threads
Dynamic Client example in Ivan Kriz's tutorial
Webservice client
How to generate a correct WSDL for a service with overloaded methods ?
web service explorer testing Web service gets right return value, java client gets wrong value
Generate XML with out JAXB