facebook

Complex return type is giving some problem.

  1. MyEclipse Archived
  2.  > 
  3. Web Services
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #267783 Reply

    nvenkatarao
    Member

    Hi,

    When I am putting return type as a HashMap in bean like
    public HashMap getInfo() {
    return map;
    }

    ..for this service I generated wsdl file and when i am generating client code that return type is generating like AnyTypeAnyType2AnyType like that but i dont want look this code …..i want return type is the same like HashMap….i tried with putting minOccurs=”1″ and nillable=”true” combination i tried …but still i did’t get any positive out put ….

    can u please any body look into this issue…

    Thanks in Advance.

    #267788 Reply

    tomeksz
    Member

    You need to tell XFire what kind of data you have in Map, in other case it don’t know how to serialize it.
    If you use java 1.4 use aegis mapping file ( you can find an example in examples/book folder in XFire distribution ). If you use Java 5 you can just “type” this map like : Map<String, Long>.
    And a little hint 🙂 probably is better to return an interface then implementation so can return Map instead of HashMap

    #267827 Reply

    nvenkatarao
    Member

    Hi Tome,

    Just now i tried with same as you said ….but when i am generating client code …..I observed in the bean class that corresponding map variable setters and getters are not generated please observe below

    This is My self created bean :-

    /**
    *
    */
    package com.rs.ws.service;

    import java.io.Serializable;
    import java.util.HashMap;
    import java.util.Map;

    /**
    * @author Nelluri
    *
    */
    public class CreateAccountRequest implements Serializable {

    /**
    *
    */
    private static final long serialVersionUID = 1L;
    private Integer accountId;

    private Map<String, String> map;

    public void addToMap(String key, String value){
    if(map == null)
    map = new HashMap();
    this.map.put(key, value);
    }

    /**
    * @return the map
    */
    public Map<String, String> getMap() {
    return map;
    }

    /**
    * @return the accountId
    */
    public Integer getAccountId() {
    return accountId;
    }

    /**
    * @param accountId the accountId to set
    */
    public void setAccountId(Integer accountId) {
    this.accountId = accountId;
    }

    /**
    * @param map the map to set
    */
    public void setMap(Map<String, String> map) {
    this.map = map;
    }

    }

    The Tool generated bean below :-

    package com.rs.ws.service;

    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlType;

    /**
    * <p>Java class for CreateAccountRequest complex type.
    *
    * <p>The following schema fragment specifies the expected content contained within this class.
    *
    * <pre>
    * <complexType name=”CreateAccountRequest”>
    * <complexContent>
    * <restriction base=”{http://www.w3.org/2001/XMLSchema}anyType”>
    * <sequence>
    * <element name=”accountId” type=”{http://www.w3.org/2001/XMLSchema}int”/>
    * </sequence>
    * </restriction>
    * </complexContent>
    * </complexType>
    * </pre>
    *
    *
    */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = “CreateAccountRequest”, propOrder = {
    “accountId”
    })
    public class CreateAccountRequest {

    @XmlElement(required = true, type = Integer.class, nillable = true)
    protected Integer accountId;

    /**
    * Gets the value of the accountId property.
    *
    * @return
    * possible object is
    * {@link Integer }
    *
    */
    public Integer getAccountId() {
    return accountId;
    }

    /**
    * Sets the value of the accountId property.
    *
    * @param value
    * allowed object is
    * {@link Integer }
    *
    */
    public void setAccountId(Integer value) {
    this.accountId = value;
    }

    }

    but i want that corresponding variable setters and getters methods….

    #267828 Reply

    nvenkatarao
    Member

    Hey Tom,

    sorry that is generating but retrun type is generating same it is look like below

    package com.rs.ws.service;

    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlType;

    /**
    * <p>Java class for CreateAccountRequest complex type.
    *
    * <p>The following schema fragment specifies the expected content contained within this class.
    *
    * <pre>
    * <complexType name=”CreateAccountRequest”>
    * <complexContent>
    * <restriction base=”{http://www.w3.org/2001/XMLSchema}anyType”>
    * <sequence>
    * <element name=”accountId” type=”{http://www.w3.org/2001/XMLSchema}int”/>
    * <element name=”map” type=”{http://service.ws.rs.com}anyType2anyTypeMap”/>
    * </sequence>
    * </restriction>
    * </complexContent>
    * </complexType>
    * </pre>
    *
    *
    */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = “CreateAccountRequest”, propOrder = {
    “accountId”,
    “map”
    })
    public class CreateAccountRequest {

    protected int accountId;
    @XmlElement(required = true)
    protected AnyType2AnyTypeMap map;

    /**
    * Gets the value of the accountId property.
    *
    */
    public int getAccountId() {
    return accountId;
    }

    /**
    * Sets the value of the accountId property.
    *
    */
    public void setAccountId(int value) {
    this.accountId = value;
    }

    /**
    * Gets the value of the map property.
    *
    * @return
    * possible object is
    * {@link AnyType2AnyTypeMap }
    *
    */
    public AnyType2AnyTypeMap getMap() {
    return map;
    }

    /**
    * Sets the value of the map property.
    *
    * @param value
    * allowed object is
    * {@link AnyType2AnyTypeMap }
    *
    */
    public void setMap(AnyType2AnyTypeMap value) {
    this.map = value;
    }

    }

    but i want how to generate return type is same as a Map element…

    #267831 Reply

    tomeksz
    Member

    Looks like something went wrong with config :/ Maybe you don’t have xfire-java5 jar in your classpath ?

    #267835 Reply

    nvenkatarao
    Member

    No Tom. … in class path i have all those jar files else that will show some compilation problem….
    in my classpath i have XFire-core jar, XFire-JAXB jar..and remain jars are there

    #267870 Reply

    tomeksz
    Member

    Nope, missing xfire-java5.jar wont give you any compilation problems. The only result is : java 5 types are not recognized 🙂

    #267889 Reply

    nvenkatarao
    Member

    Hi Tom,

    In my class path xFire-Java5-1.2.2.jar is there ..along this and all jars are there…..just now also I checked all jars are there……
    Why exactly that is generating AnyType2AnyType like that…….i tried in different ways also but …….Please look into this issue…

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: Complex return type is giving some problem.

You must be logged in to post in the forum log in