Null response object from Java Web Service
Hi all,
I did not found any anything specific to web service, hence though of posting my question here:
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:
Code:
<!--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. Ask if you want some specific information about the same.
Regards,
Re: Null response object from Java Web Service
Re: Null response object from Java Web Service
Reason:
I did not get any reply, hence thought of posting it in different forums.
If you knw the reason, then can you please reply?
Regards,
Re: Null response object from Java Web Service
What does your response look like?
You should be able to get it from something like soap ui if you;re not already logging it.
Re: Null response object from Java Web Service
Quote:
Originally Posted by
Tolls
What does your response look like?
You should be able to get it from something like soap ui if you;re not already logging it.
The response is basically a model with some values. You can get the model details from the WSDL as well.
Another thing to notice is like when i create the WSDL, the the _SEI file is not getting generate for my service, nor the _helper, _ser and _deser are getting generated for the model.
Regards,
Re: Null response object from Java Web Service
I tend to go from WSDl to code, and not vice-versa.
Anyway, when I asked what it looks like, I meant what it looks like.
When you fire off your request what do you get back?
You say you get a null response object, but I want to know what you see with soap ui.
Re: Null response object from Java Web Service
Code:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<fetchEmployeeDetailsResponse xmlns="http://service.com">
<fetchEmployeeDetailsReturn>
<age>0</age>
<deptId>0</deptId>
<empId>0</empId>
<empName xsi:nil="true"/>
<sex xsi:nil="true"/>
</fetchEmployeeDetailsReturn>
</fetchEmployeeDetailsResponse>
</soapenv:Body>
</soapenv:Envelope>
This is what i am getting back in SOAP UI
Re: Null response object from Java Web Service
So it's not a null response.
There's data in there, coming from that service.
If that data is wrong then I would be looking at the service and not the WSDL.
Re: Null response object from Java Web Service
Hi,
But that is not the expected data. What may be the problem?
Regards,
Re: Null response object from Java Web Service
Something in your web service is populating the data incorrectly.
Debug it.
See where in the service it gets to.
Re: Null response object from Java Web Service
Quote:
Originally Posted by
butny
Hi Bill/James,
Pardon?
Quote:
Originally Posted by
butny
I got a clue but not sure why
i have this piece of code for fetching the connection object:
Code:
public static Connection getConnection(){
try{
Class.forName("oracle.jdbc.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521/orcl","userId","password");
System.out.println("Connected Successfully!!!");
}catch (Exception e) {
e.getMessage();
}
return conn;
}
When i try to debug it using main method(as a POJO, then its working fine.
But when i test it using SOAP UI, then the below line is throwing a NullPointerException i.e. the Connection object is having NULL values.
Why is it like working when tested using POJO but not working when tested using SOAP UI? I have classes12.jar in my classpath.
I dont have a answer for the same :(
Please tell how to resolve this :(
Regards,
You never log the exception anywhere, because there *is* an exception.
And then you continue happily on.
Throw the Exception, since you cannot recover from it.
It will then precolate back to your client and you can finally see what the problem is.
Re: Null response object from Java Web Service
Oh yes, and unless you are using Java 1.2 or 1.3 then you should really be using ojdbc4.jar against 10g.
Re: Null response object from Java Web Service
The problem was with the connection with DB issue. I placed the jar file classes12.jar in the lib folder of WEB_INF and it worked for me. Anyways, moving forward i will take care of replacing the older jar with odbc4.jar
I am not able to understand a few things:
1) Why is there no _SEI, ser, deser and helper created (i asked in the previous post)
2) what are the use of _SEI, ser, deser and helper files? In IBM RSA and WebSphere i can see these files (in that case I use the RPC approach, use the webservices.jar rather than using axis.jar). Is it like these generated files are needed for AXIS but not for IBM RPC?
Totally confused with these two questions
Please clear my confusion.
Regards,
Re: Null response object from Java Web Service
No idea.
They're not needed for a web service, or even JAXB, so I suspect it's some Axis thing or even server specific.