• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

webservice using servlet

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to use the google api. I am able to query and get the response from the google webservice if i execute my standalone java program in the command line. But if i make the same java program into a servlet I am getting the following exception:
Unable to create SOAP connection factory: Provider org.apache.axis.soap.SOAPConnectionFactoryImpl not found.

Here is my code :
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.*;

import javax.xml.soap.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;



public class SoapClient extends HttpServlet
{
SOAPConnectionFactory scf;
SOAPConnection connection;
SOAPFactory sf;
MessageFactory mf;
SOAPMessage message;
SOAPMessage resp;
SOAPPart soapPart;
SOAPEnvelope envelope;
SOAPBody body;
URL endpoint;
TransformerFactory tf;
Transformer transformer;
StreamResult result;
Source content;


public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{



try
{
//Create the connection
scf = SOAPConnectionFactory.newInstance();
connection = scf.createConnection();
sf = SOAPFactory.newInstance();
//Create the message
mf = MessageFactory.newInstance();
message = mf.createMessage();
soapPart = message.getSOAPPart();
envelope = soapPart.getEnvelope();
body = envelope.getBody();
//Populate the body of the message
Name bodyName = sf.createName("getPrice", "ns1", "urn:xmethods-BNPriceCheck");
SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
Name name = sf.createName("isbn");
SOAPElement isbn = bodyElement.addChildElement(name);
isbn.addTextNode("0596002432");

//Display the request sent (Code Sample 1)
System.out.println("SOAP Request Sent:");
message.writeTo(System.out);

//Set the destination
endpoint = new URL("http://services.xmethods.net:80/soap/servlet/rpcrouter");
//Send the message
resp = connection.call(message, endpoint);
//Close the connection
connection.close();

//Display the resp received (Code Sample 3)
System.out.println("SOAP Response Received:");

//Create a transformer
tf = TransformerFactory.newInstance();
transformer = tf.newTransformer();
//Retrieve content of the response
content = resp.getSOAPPart().getContent();
//Display it on the console
result = new StreamResult(System.out);
transformer.transform(content, result);
}
catch(Exception e)
{
System.out.println(e.getMessage());
}

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>testing</title>");
out.println("</head>");
out.println("<body bgcolor=\"white\">");
//out.println(t.show("jingbang"));
out.println("srinivas </body></html>");

}

/*
public static void main(String arg[])
{

}
*/

}
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error
org.apache.axis.soap.SOAPConnectionFactoryImpl not found.
would appear to indicate that you just need to put the jar file containing the org.apache.axis.soap package where the servlet engine can see it.
Note that if you are using Tomcat, Tomcat totally ignores your environment classpath.
See the documentation that tomcat comes with tomcat-docs/class-loader-howto.html
Bill
 
sreenevas varkala
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:
Thank u. I understood what you are saying. I am using tomcat, so I will go thru the documentation.
Thanks once again,
srinivas.
 
sreenevas varkala
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mr Bill
After reading the tomcat docs I was able to figure out the if's n but's of tomcat class loaders. I was also able to solve my servlet problem.

Thanks a lot,
srinivas.
reply
    Bookmark Topic Watch Topic
  • New Topic