wood burning stoves 2.0*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Query Regarding WSIMPORT generated Artifacts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Query Regarding WSIMPORT generated Artifacts" Watch "Query Regarding WSIMPORT generated Artifacts" New topic
Author

Query Regarding WSIMPORT generated Artifacts

Jolly Tiwari
Ranch Hand

Joined: Mar 26, 2006
Posts: 77
Hi! Everyone,

I have a query regarding the Artifacts (especially the Port class) generated by wsimport.
I took following two documents :
1. StringProcessorService.wsdl
2. StringProcessorService_Payload.xsd

Reference: snippets taken from IVAN's guide

I Placed both the documents in a directory and then executed wsimport on my command prompt:

c:\wsdl\>wsimport -p clientside -s . StringProcessorService.wsdl


StringProcessorService.wsdl




StringProcessorService_Payload.xsd



Doubt:
When I am looking at the code generated inside the Port class(StringProcessorPort.java) I found following

public ReverseStringResponse reverseString(
@WebParam(name = "reverseStringReq", targetNamespace = "http://www.instinct.com/stringprocessor", partName = "parameters")
ReverseStringRequest parameters);

The parameters and return type are of ReverseStringRequest and ReverseStringResponse respectively.
I guess the wsdl and xsd tells that they should be of String type.

Please correct me if i am wrong.

Regards

Jolly
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Jolly Tiwari wrote:
The parameters and return type are of ReverseStringRequest and ReverseStringResponse respectively.
I guess the wsdl and xsd tells that they should be of String type.

No, the WSDL does not say that they are of the type String, however, both the request and response objects do contain one string. How can you tell? Well, look at the <portType> element of the WSDL. I have added some comments.


Next, we take a look at the XML schema that defines the reverseStringReq and reverseStringRes elements:


It declares two datatypes, one for the request and one for the response, that both contains a single string each. If we look at the request, then the <inString> element that will contain the string indata of the request will be contained in a <reverseStringReq> element - the name of the complex type of the element in the request message.
Hope this makes things more clear!


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

Joined: Mar 26, 2006
Posts: 77
Thanks Ivan for your quick response

Well that means one of the class generated by wsimport,StringProcessorPort is fine.

public ReverseStringResponse reverseString(
@WebParam(name = "reverseStringReq", targetNamespace = "http://www.instinct.com/stringprocessor", partName = "parameters")
ReverseStringRequest parameters);


To invoke this service operation through Proxy mechanism , We will have to create an instance of JAXB mapping class for Request data and then call its setter method to provide input data which is a String in this case.



Query
What changes need to be done to enable the client to invoke service operation as follows

StringProcessorService srvc=new StringProcessorService();
StringProcessorPort port=srvc.getStringProcessorPort();
String res=port.reverseString("Hello");



Please correct me wherever you feel i am wrong as that would be of great help.

Regards

Jolly
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Jolly Tiwari wrote:
Query
What changes need to be done to enable the client to invoke service operation as follows



You would need to modify the WSDL or write the proxy classes by hand.
The main point with this example in my study notes is to show how a web service that consumes entire protocol messages, such as SOAP messages or XML messages. This is something that is more likely to be used when developing a document-based web service (as opposed to a RPC web service). If you are implementing a web service endpoint class that implements the Provider interface, you are not very likely to have simple types as parameters.
Best wishes!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Query Regarding WSIMPORT generated Artifacts