0

I tried running the Web Service as a java application by adding a main method in the service, i got all the model values getting populated perfectly. There are some DAO operations with Oracle 10g DB, have classes12.jar in my classpath.

Then i created a wsdl and tested it in SOAP UI. There I can see that the service is returning a null object as response.

The wsdl was created using Apache AXIS v1.4.

This means the wsdl getting generated is not correct since all my code is working fine when i run it as java client application.

Additional Info:

When the return type of a method present in the web service is integer, then the value is getting returned correctly while invoking the Web Service using SOAP UI. But when i try to return a model, a null response object is returned.

WSDL:

<!--WSDL created by Apache Axis version: 1.4
 Built on Apr 22, 2006 (06:55:48 PDT)-->
 <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="http://service.com"   xmlns="http://www.w3.org/2001/XMLSchema">
  <import namespace="http://model.com"/>
  <element name="getAge">
   <complexType/>
  </element>
  <element name="getAgeResponse">
   <complexType>
    <sequence>
     <element name="getAgeReturn" type="xsd:int"/>
    </sequence>
   </complexType>
  </element>
  <element name="fetchEmployeeDetails">
   <complexType>
    <sequence>
     <element name="empId" type="xsd:int"/>
    </sequence>
   </complexType>
  </element>
  <element name="fetchEmployeeDetailsResponse">
   <complexType>
    <sequence>
     <element name="fetchEmployeeDetailsReturn" type="tns1:EmployeeDetails"/>
    </sequence>
   </complexType>
  </element>
 </schema>
 <schema elementFormDefault="qualified" targetNamespace="http://model.com"    xmlns="http://www.w3.org/2001/XMLSchema">
  <complexType name="EmployeeDetails">
   <sequence>
    <element name="age" type="xsd:int"/>
    <element name="deptId" type="xsd:int"/>
    <element name="empId" type="xsd:int"/>
    <element name="empName" nillable="true" type="xsd:string"/>
    <element name="sex" nillable="true" type="xsd:string"/>
   </sequence>
  </complexType>
 </schema>
</wsdl:types>

  <wsdl:message name="fetchEmployeeDetailsResponse">

  <wsdl:part element="impl:fetchEmployeeDetailsResponse" name="parameters">

  </wsdl:part>

  </wsdl:message>

  <wsdl:message name="getAgeRequest">

     <wsdl:part element="impl:getAge" name="parameters">

     </wsdl:part>

  </wsdl:message>

  <wsdl:message name="getAgeResponse">

     <wsdl:part element="impl:getAgeResponse" name="parameters">

     </wsdl:part>

  </wsdl:message>

  <wsdl:message name="fetchEmployeeDetailsRequest">

     <wsdl:part element="impl:fetchEmployeeDetails" name="parameters">

     </wsdl:part>

  </wsdl:message>

  <wsdl:portType name="WebService1">

     <wsdl:operation name="getAge">

        <wsdl:input message="impl:getAgeRequest" name="getAgeRequest">

      </wsdl:input>

        <wsdl:output message="impl:getAgeResponse" name="getAgeResponse">

      </wsdl:output>

     </wsdl:operation>

     <wsdl:operation name="fetchEmployeeDetails">

        <wsdl:input message="impl:fetchEmployeeDetailsRequest" name="fetchEmployeeDetailsRequest">

      </wsdl:input>

        <wsdl:output message="impl:fetchEmployeeDetailsResponse" name="fetchEmployeeDetailsResponse">

      </wsdl:output>

     </wsdl:operation>

  </wsdl:portType>

  <wsdl:binding name="WebService1SoapBinding" type="impl:WebService1">

     <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

     <wsdl:operation name="getAge">

        <wsdlsoap:operation soapAction=""/>

        <wsdl:input name="getAgeRequest">

           <wsdlsoap:body use="literal"/>

        </wsdl:input>

        <wsdl:output name="getAgeResponse">

           <wsdlsoap:body use="literal"/>

        </wsdl:output>

     </wsdl:operation>

     <wsdl:operation name="fetchEmployeeDetails">

        <wsdlsoap:operation soapAction=""/>

        <wsdl:input name="fetchEmployeeDetailsRequest">

           <wsdlsoap:body use="literal"/>

        </wsdl:input>

        <wsdl:output name="fetchEmployeeDetailsResponse">

           <wsdlsoap:body use="literal"/>

        </wsdl:output>

     </wsdl:operation>

  </wsdl:binding>

  <wsdl:service name="WebService1Service">

     <wsdl:port binding="impl:WebService1SoapBinding" name="WebService1">

        <wsdlsoap:address location="http://localhost:8045/WebService1/services/WebService1"/>

     </wsdl:port>

  </wsdl:service>

Please help me out of this. If some additional information is required then please ask.

Regards,

1 Answer 1

1

The mistake was to do the unit testing using main method and running it as java application from main method. The problem was related to classes12.jar placement. For Web app, jars should be placed ibside the lib folder. But it is not the same for a Java client app. Hence, the connection object was not getting retrieved properly when I tries to run it using the SOAP UI.

Conclusion:

Never test web services by adding a main method in service class and running it as a java client application, it may cause you unnecessary problems like this one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.