ObjectFactory class generated from wsdl missing Factory Metods

Viewed 702

I have searched for this in Internet but unable to find a answer.

I am new to SOAP services, If I am wrong at any point please correct me. I was trying to generate Java classes from wsdl using command line tool ** JAX-WS RI wsimport**. I was able to generate all Request and Response classes. The ObjectFactory.java generated from wsdl was missing most of the methods.

employee.wsdl.jaxb.bnd.xml

<jaxb:bindings version="2.0"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb/xjc">
    <jaxb:bindings>
        <jaxb:globalBindings generateElementProperty="false">
              <xjc:serializable>
         </jaxb:globalBindings>
    </jaxb:bindings>
</jaxb:bindings>

employee.wsdl.bnd.xml

<jaxws:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
     xmlns="http://java.sun.com/xml/ns/jaxws"
     xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
     wsdlLocation="../sp.wsdl">
     <jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>

In jaxb.bnd.xml While trying with <jaxb:globalBindings generateElementProperty="true"> Its able to generate all of the factory methods. But it was using JAXBElement<> wrapper for primititve data types like String,int,Long

While trying with <jaxb:globalBindings generateElementProperty="fasle"> Its able to generate the class without JAXBElement<> wrapper, but missing most of the factory methods.

cmd: wsimport META-INF/wsdl/employee.wsdl -keep -b META-INF/wsdl/bindings/employee.bnd.xml -b META-INF/wsdl/bindings/employee.jaxb.bnd.xml -wsdllocation META-INF/wsdl/employee.wsdl

Sample ObjectFactory.java

package xyz;

@XmlRegistry
class ObjectFactory {
      
     private final static Qname _EmpDetailsSpecialEmpDetail_QNAME = new QName("", "scheduleEmp");
      
     @XmlElementDecl(namespce = "", name="specialEmployee", scope= EmpDetails.class)
     public SpecialEmpDetail EmpDetailsSpecialEmployee(SpecialEmpDetail value) {
           return new SpecialEmpDetail(_EmpDetailsSpecialEmpDetail_QNAME, SpecialEmpDetail.class, EmpDetail.class, value); 

}

EmpDetail.java

public class EmpDetail implements Serializable {
  @XmlElementRef(name= "specialEmployee", required=false)
  protected SpecialEmpDetail specialEmployee;
  
  public SpcialEmpDetail getSpecialEmployee() {
      return specialEmployee;
  }

  public SpcialEmpDetail setSpecialEmployee(SpcialEmpDetail value) {
      this.specialEmployee = value;
  }
}

SpecialEmpDetail.java

public class SpecialEmpDetail {
     //local var
     //getter and setter
     .....
}

employee.wsdl

<?xml version="1.0" encoding="UTF-8">
<definitions name="psp"
  targetNamespace="http://www.namespace.com/employee.wsdl"
  .....
  />
<types>
   <schmea targerNamespace = "http://www.namespace.com/employee.wsdl"
         xmlns:SOAP-ENV = "http://www.w3.org/2003/05/soap-envelope"
         xmlns:xsi = "http://www.w3.org/2003/05/XMLSchema-instance"
         xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
         xmlns:emp = "http://www.namespace.com/employee/employee.xsd1"
         <import namespace="http://www.namespace.com/employee.xsd1"/>
         <import namespace="http://www.w3.org/2003/05/soap-encoding"/>
   </schmea>
   <schmea targerNamespace = "http://www.namespace.com/employee.xsd1"
         xmlns:SOAP-ENV = "http://www.w3.org/2003/05/soap-envelope"
         xmlns:xsi = "http://www.w3.org/2003/05/XMLSchema-instance"
         xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
         xmlns:emp = "http://www.namespace.com/employee/employee.xsd1"
         <import namespace="http://www.namespace.com/employee.wsdl"/>
         <import namespace="http://www.w3.org/2003/05/soap-encoding"/>
         <simpleType name="empName">
           <restrictions base="xsd:string">
           <minLength value="1"/>
           <maxLength value="30"/>
           </restrictions>
         <simpleType name="EmpID">
           <restrictions base="xsd:string">
            <minLength value="0"/>
            <maxLength value="25"/>
           </restrictions>
        </simpleType>

   <complexType name="">
     <sequence>
       <element name="specialEmployee" type="emp:SpecialEmpDetail minOccurs="0" maxOccurs="1" />
    </sequence>
  </complexType>
 .....
 .........
 </schema>
</types>

Here is the sample wsdl and java. I can able to generate SpecialEmpDetail.java & EmpDetail.java The ObjectFctory.java should create the mentioned function, but its failed to do so.... Using JAXBElement<> wrapper I can able to generate all functions but the problem here is its a complextType data so wrapping is fine, But String also wrapped this is not expected.

What may be problem?? How can I resolve it??

Thanks in Advance!

0 Answers
Related