File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes problem while calling document style web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "problem while calling document style web service" Watch "problem while calling document style web service" New topic

problem while calling document style web service

Harsh Cap

Joined: Mar 04, 2010
Posts: 6

I am devloping a one webservice and hosted TestEmployee as a web service i am using addEmployee as a web service method which take Employee as a parameter. My problem is that i am getting employee as null in my method.

I am preparing the soap request in a servlet please find below code for my my soap request:

SOAPPart sp = msg.getSOAPPart();

SOAPEnvelope env = sp.getEnvelope();

SOAPBody bd = env.getBody();
Document document=getDocument(emp);


// View input
System.out.println("\n Soap request:\n");
return msg;

Once that code execute my soap request came like this:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:enc="" xmlns:env="" xmlns:xsd="" xmlns:xsi="" SOAP-ENV:encodingStyle=""><SOAP-ENV:Header/><SOAP-ENV:Body><emp:getEmployee xmlns:emp="http://localhost:8008/DocStyleWS/BO/Employee"/><employee><empId>26155</empId><empName>Harsh</empName></employee></SOAP-ENV:Body></SOAP-ENV:Envelope>

Below is the code how I call my webservice:

SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection conn = scf.createConnection();

// Send
String urlval = "http://localhost:8008/DocStyleWS/services/TestEmployee";
// or /rcx-ws-rpc/rcx for my rpc/encoded web service

SOAPMessage rp =, urlval);

// View the output
System.out.println("\nXML response\n");

// Create transformer
TransformerFactory tff = TransformerFactory.newInstance();
Transformer tf = tff.newTransformer();

// Get reply content
Source sc = rp.getSOAPPart().getContent();

// Set output transformation
StreamResult result = new StreamResult(System.out);
tf.transform(sc, result);


StreamResult fileResult = new StreamResult(new File("C:\\Harsh\\output.xml"));
tf.transform(sc, fileResult);

// Close connection

MY web service code look like this:

public String addEmployee(Employee emp){
System.out.println("In Add employee method");
empList.add(emp.getEmpId().intValue() ,emp);
System.out.println("Employee Added Sucessfully");
return "Emp Added";

I am getting the fault code in my soap response please find it below:

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi=""><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server.userException</faultcode><faultstring>java.lang.NullPointerException</faultstring><detail><ns1:hostname xmlns:ns1="">PUNDT8X2KQ1S</ns1:hostname></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>

Please help me as i already invest my 5 days to get this error resolve.


Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
Have you tried using soapUI or some other tool to send a request to the web service?
Using soapUI, you can determine if the problem is your client sending bad data to the service or if the problem is in the service.
Best wishes!
Harsh Cap

Joined: Mar 04, 2010
Posts: 6

Thanks for your intrest ....

I am using Servlet to make a soap request and call my web service from the servlet. All the above code is a part of Servlet. I never tried SoapUI for creating soapRequest. Could you please tell me how can I call my web service from Servlet witout using any tool.

Thanks in advance.

Harsh Cap

Joined: Mar 04, 2010
Posts: 6

Hi Ivan

As you suggest i tried to make a soap request through soapUI and found that the request which i previously make was not correct because of that i am not able to invoke my web service.

I modify my request and now I am able to call my web service.

Thanks a ton for your suggestion.


I agree. Here's the link:
subject: problem while calling document style web service
It's not a secret anymore!