aspose file tools*
The moose likes Web Services and the fly likes accessing attribute value from response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "accessing attribute value from response" Watch "accessing attribute value from response" New topic
Author

accessing attribute value from response

Jomy George
Ranch Hand

Joined: Jan 13, 2011
Posts: 65
Hi friends,

I am using wsdl2Java for generating java class from WSDL.
when running this WSDL in soapUI i can see some attributes.
But in generated class i can't see variables, getter, and setters for these attributes.

for example if i can see like this in soapUI
<person sex="female">
<firstname>Anna</firstname>
<lastname>Smith</lastname>
</person>

in WSDL2Java produced java code, i couldnt find a variable named sex, but firstname, lastname are there.
Any solution for solving it?

Thanks in advance.....
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
    
    4
0. Just Search for the text 'person' among the java and/or xml files generated. You probably see it.

1. if wsdl2java is running fine, then you should have client artifacts/code generated to call the web service provider.
(what is your soap engine? AXIS1, AXIS2, CXF etc...)

2. Pseudo-code/basic idea, for example:
RequestClass request=new RequestClass();
request.setParameter(x);
etc...

ResponseClass response = webservice.call (request);

then the response object will have the value for its property/fields defined.

3. Just code the point 2 and use the IDE debugger to see/examine response object. I used Eclipse IDE. Good luck.

Jomy George
Ranch Hand

Joined: Jan 13, 2011
Posts: 65
Thanks Paul,

In my file it looks like this.


and i tried to add sex like this. also added variable, getter and setter for sex.
but on accessing that variable i am getting null.
Jomy George
Ranch Hand

Joined: Jan 13, 2011
Posts: 65
on searching in Google i found some links

https://issues.apache.org/jira/browse/AXIS-2391. it says WSDL2Java ignore attibutes for complex types.

any idea?
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
    
    4
1. Here is a test wsdl

2. I generated client code using AXIS1 WSDL2JAVA
3. I used it

4. I just wonder why don't you use the Locator class generated as the starting point for invoking the service provider.
5. If possible, can you list the file names generated by the wsdl2java?
Was there any error during the wsdl2java process?


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: accessing attribute value from response