Web services writen in Servlet ?

Who can tell me that servlet can write a web services? And If can, what is the software that can use to write the web services using servlet. Thanks for helping me.

If you mean SOAP web services, yes you can, but most of the time you will expose a JavaBean or EJB using a SOAP toolkit installed into your servlet engine. The SOAP engine will be a servlet, but your web service will be a class.
If you mean serving XML data using a servlet/jsp? yes you can, and in this case you just do it using simple Java code inside your service method(). Set the content type to "text/xml" and send a string containing the xml. This is like home-made web services, very lightweight.
There is also another web services protocol called XML-RPC. In Java it may be implemented as a servlet (the web service engine), but again exposing some java class as the service
Resin servlet engine (www.caucho.com) is an awsome product, free for development, $500 for production server, that includes the most simple and trouble free implementation of xml web services, using a propietary protocol.
Regards,
Martin Cordova
http://www.martincordova.com
Dinamica framework for J2EE
- the easiest way to Java webapps...

Similar Messages

  • Web service proxy and servlet

    Hi,
    i use jdev 10.1.3.4 and i follow the tutorial "developping,depoying and managing web services using jdeveloper.
    I try to use the proxy for the web service from a servlet like in the main method of the proxy :
    HelloSoapHttpPortClient myPort = new HelloSoapHttpPortClient();
    System.out.println("calling " + myPort.getEndpoint());
    System.out.println(myPort.sayHello("didier823"));
    and i got this error :
    10/03/10 16:58:02 not an interface: services1.Hello
    How can use the proxy generated by jdev from a servlet or a jsp ?
    Thank you for your help !

    Hi,
    i find a solution i regenered a new proxy with another package and it works fine
    i can use the proxy from my servlet to call the ejb web service.
    Bye.

  • Calling a web service from a servlet via stub: java.lang.reflect.Invocation

    Hi all, I'm developping my first web application using Apache Tomcat and Axis, using servlets, jsp and web services.
    My problem is that I cannot make any call to my web service (a very simple one) because I get the following exception:
    <code>
    java.lang.reflect.InvocationTargetException CAUSA: null
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.lang.reflect.InvocationTargetException
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}hostname:lexis02
    java.lang.reflect.InvocationTargetException
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
    at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    </code>
    The stack trace is longer than that, but I didn't find any hints to solve the problem.
    The exception is thrown for every method of the web service:

    public java.lang.String[] getMessage(java.lang.String , int) throws java.rmi.RemoteException
    public boolean addMessage(java.lang.String, java.lang.String, int)
    throws java.rmi.RemoteException
    I'm using stub to call the web service, as generated by wsdl tool.
    Can someone help me?
    Thanx
    PS: sorry for the double message but I pressed the wronk key at the wrong time :)

  • Consuming a web service from a Servlet on OC4J

    In my web application, I have a servlet, and that servlet calls a webservice running on an external server. To connect to the web service, I am using a java proxy class that was generated using the WebServicesAssembler tool (the webservice runs on an OC4J server). When I use the proxy in a stand alone application, it works fine. Unfortunately, when I try to use it in my servlet, I get a SOAP Exception. This is some information I get from my log.
    2007-07-23 11:36:39,861 [HttpRequestHandler-19288329] INFO
    Message: Unsupported response content type "text/html", must be: "text/xml". Response was:
    <HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>404 Not Found</H1>Resource /webservices/StationService/ not found on this server</BODY></HTML>
    2007-07-23 11:36:39,861 [HttpRequestHandler-19288329] INFO [com.georss.GeoRss:190] - Cause: null
    2007-07-23 11:36:39,861 [HttpRequestHandler-19288329] INFO
    Localized Message: Unsupported response content type "text/html", must be: "text/xml". Response was:
    <HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>404 Not Found</H1>Resource /webservices/StationService/ not found on this server</BODY></HTML>
    2007-07-23 11:36:39,861 [HttpRequestHandler-19288329] INFO
    Fault Code: SOAP-ENV:Protocol
    So from the error message in the Localized message, it seems like the application is receiving a 404 error. In the proxy stub code, I know the url for the service is correct, so I dont know why it is not working. Any idea?
    Thanks.
    Message was edited by:
    Mynameisbt

    I am sure that the URL is right because I can use the same client class for the web service in a stand alone application. I did not change the endpoint URL in the client at all. The client was generated by OC4J's web services assembler tool. Also, the same URL will work in a browser.
    Does OC4J require some sort of deployment descriptor to connect to an external web service? My web application only uses a .war file and it is packaged in an .ear file. It is a J2EE 1.3 application.
    this is what I have in my web.xml file:
    <web-app>
    <servlet>
    <servlet-name>myServlet</servlet-name>
    <display-name>myServlet</display-name>
    <description>description</description>
    <servlet-class>com.controller</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>myServlet</servlet-name>
    <url-pattern>/servlet/myServlet</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    </web-app>
    In my web.xml descriptor, do I need to add anything related to the web service i am trying to access?
    Message was edited by:
    Mynameisbt

  • Sabre web service call from servlet

    hi all:
    I need to call sabre web service from my application. sabre have provided one utility (bat file for windows environment), this is working fine. I have just created servlet and called this web service in the same way as this batch file calling using java program.
    I am facing below problem while calling this sabre web service.. I am facing this problem.
    XSL-1900: (Fatal Error) An internal error condition occurred.
    05/07/21 17:10:05 java.io.IOException: SOAP exception while trying to externalize: Unable to create envelope from given source: XSL-1900: (Fatal Error) An internal error condition occurred.
    05/07/21 17:10:05 at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getContentAsStream(SOAPPartImpl.java:189)
    05/07/21 17:10:05 at com.sun.xml.messaging.saaj.soap.SOAPPartImpl$1.getInputStream(SOAPPartImpl.java:232)
    05/07/21 17:10:05 at javax.activation.DataHandler.writeTo(DataHandler.java:297)
    05/07/21 17:10:05 at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1089)
    05/07/21 17:10:05 at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:635)
    05/07/21 17:10:05 at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:233)
    05/07/21 17:10:05 at com.sun.xml.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:372)
    05/07/21 17:10:05 at com.sun.xml.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:399)
    05/07/21 17:10:05 at com.sabre.universalservices.wsclient.SoapClient.sendSoapMessage(SoapClient.java:112)

    Hai ,
    I am new to this sabre web service. now we are using eSAPI connection to connect to Sabre.
    we want to upgrade it into "sabre web service".
    will you please help on this...
    I don't know how to start...
    please give your mail ID.... My Id is [email protected]
    Thanks !!!!!!!

  • Web services with axis & servlets ????

    Hi !
    Iwould like to know if it is possible to reach a tomcat servlet when we are running a service with axis integrated in tomcat : can we use the servetcontext and share it between tomcat & axis ????
    TU a lot...
    PA

    Hi,
    As far as I know if Apache soap used to implemented as a servlet. If axis is implemented the same way ( I am not sure about this), then it should be able the share the context with other servlets within the container. Hope this helps.
    Cheers,
    Arun

  • How 2 connect you web service with your servlet

    I created a webservice in netbeans and i also created a client side where clients get to view the site but i have a problem i can't connect my webservice to my client as and i can't connect my webservice to my database. please help me if you can by showing me the coding

    Hi , I want to intercept the webservice call using a servlet ..
    how would i do this

  • Web service, servlet, HttpServletResponse, Locale

    Hello guys!
    I have two questions:
    - Can a servlet be a web service?
    - For the next one, I supposed that yes... I'm trying to build a web service from a servlet and I get a strange error.
    I simplified the code to the maximum, and it became like this:
    public class PriceListServlet extends HttpServlet implements PriceListIF{
        public void init() {
         public void doPost(HttpServletResponse resp) {
              }and the interface is:
    public interface PriceListIF extends Remote {
         public void init() throws RemoteException;
         public void doPost(HttpServletResponse resp)throws RemoteException;
    }Cannot be more simple, can it?
    When I type ant build, I get the following error message:
    erreur : La classe java.util.Locale n'a pas de constructeur vide accessible public
    which means:
    error: Class java.util.Locale doesn't have public empty constructor
    I did a few tests, and if I put HttpServletRequest instead of HttpServletResponse, it works.
    If the doPost method doesn't have any parameter, it works!
    So there's a problem with HttpServletResponse...
    Does anyone know what's Locale got to do with HttpServletResponse????
    Thanks for your help
    Philippe

    Hello guys!
    I have two questions:
    - Can a servlet be a web service?
    - For the next one, I supposed that yes... I'm trying to build a web service from a servlet and I get a strange error.
    I simplified the code to the maximum, and it became like this:
    public class PriceListServlet extends HttpServlet implements PriceListIF{
        public void init() {
         public void doPost(HttpServletResponse resp) {
              }and the interface is:
    public interface PriceListIF extends Remote {
         public void init() throws RemoteException;
         public void doPost(HttpServletResponse resp)throws RemoteException;
    }Cannot be more simple, can it?
    When I type ant build, I get the following error message:
    erreur : La classe java.util.Locale n'a pas de constructeur vide accessible public
    which means:
    error: Class java.util.Locale doesn't have public empty constructor
    I did a few tests, and if I put HttpServletRequest instead of HttpServletResponse, it works.
    If the doPost method doesn't have any parameter, it works!
    So there's a problem with HttpServletResponse...
    Does anyone know what's Locale got to do with HttpServletResponse????
    Thanks for your help
    Philippe

  • Consuming a Web Service using JSP and servlet

    I have created a Web Service in Netbeans IDE 5.5. I developed a JSP to provide input to the Web Service, and a servlet that will pass the input to the web service through a request and outputs the result.
    I am getting the following error:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Servlet.init() for servlet TestServlet threw exception
    root cause
    java.lang.RuntimeException: WEB5002: Exception in handleBeforeEvent.
    root cause
    com.sun.enterprise.InjectionException: Exception attempting to inject Env-Prop: test.org.TestServlet/service@Field-Injectable Resource. Class name = test.org.TestServlet Field name=[email protected]@@@ into class test.org.TestServlet
    root cause
    javax.naming.NamingException [Root exception is java.lang.reflect.InvocationTargetException]
    root cause
    java.lang.reflect.InvocationTargetException
    root cause
    javax.xml.ws.WebServiceException: java.io.FileNotFoundException: http://localhost:8080/TestWebApplication/TestWSService?wsdl
    root cause
    java.io.FileNotFoundException: http://localhost:8080/TestWebApplication/TestWSService?wsdl
    note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server Platform Edition 9.0_01 logs.
    Any hints???

    You probably should post to either the NetBeans website mailing list, or the Sun forum that supports the Sun Application Server, as the error is the result of a configuration error of one or both of these products. A file can't be found:
    java.io.FileNotFoundException: http://localhost:8080/TestWebApplication/TestWSService?wsdl
    note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server Platform Edition 9.0_01 logs.
    These forums are for support of the Java language.

  • How to call Web Service from Servlet !

    Dear All,
    I am in dire need to understand how to call a web service from Servlet.
    I need to develop a web service which will read LDAP Directory server to retreive information.
    How I should call that web service from a Servlet? What Servlet actions do I need to write etc.
    I need guidance about design of the above task please.
    I would higly appreciate any help and guidance in this regard.
    Thanks.
    Regards,
    Waqar

    You can use java.net.URLConnection for that.

  • Question about the distribution of web service or servlet

    Hello,
    I don not know how to distribute a web servcie or servlet on the web server. I can only use this web service with the open state of the glassfish. If I close the glassfish server, the servlet cannot be accessed.
    I just want the web service or the servlet to be disributed on the web server. Web service and the servlet are available when the web server is on.
    anybody can help me?
    thank you in advance.
    MyJ2EE

    If u choose one of the smart phone once you upgrade your equipment you will have to select a data package of Unlimited Email & web for $29.99/mo.. It will not go towards your minutes the purpose of the plan is to give you unlimited use of the internet and email on your device.If you choose to change your calling plan minutes make sure you review the plan that you're already on and the mins being used to make sure if you decide to go higher or lower in minutes that you choose the plan fits your minutes used.. 

  • Servlet Calling Web Service

    Hi
    I need to call a web service via a servlet
    Both web service and servlet files are located on the same PC , but in a different directories
    the web service is working OK when I use a command line,
    However , when I try to use a Servlet method to activate the web service and retrieve some information public void doPost (HttpServletRequest request,HttpServletResponse response)  throws   ServletException ,IOException{
    serve.businessVector = (Vector)uddiClient.getuddiInformation("dublin");
    The service Client is the activated ok and when the programm reaches a particular point in the code    Service service = new Service(); I receive an error as follows
    java.lang.NoClassDefFoundError
         at org.apache.axis.client.Service.getAxisClient(Service.java:143)
         at org.apache.axis.client.Service.<init>(Service.java:152)
    Could someone please direct me on what is going on
    Or am I using the wrong approach ?
    and here is the method I am using for the service client
    public Vector getuddiInformation(String location )throws Exception {
    String endpoint = "http://localhost:8080/axis/UDDIRegistry.jws"; // here where the jwsfile is located
    // set the end point ie the URL for the call
    Service service = new Service();               
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress(new java.net.URL(endpoint));
    call.setOperationName("readXML");
    // now invoke the method in the registry
    // ie  int the UDDIRegistry.jws
    Vector ret = (Vector) call.invoke(new Object[] {new String(location)});
    uddClientVector = ret ;
    return  uddClientVector;
    }Thanks
    IB

    java.lang.NoClassDefFoundErrorYour classpath is apparently incorrect, to put it
    simply. When you "run it from the command line" you
    are running it differently, with a different
    classpath than you are when this is encountered. This
    being a J2EE app, your WAR or EAR file (or
    directory-exploded equivalent) needs to contain all
    the dependent classes/jars, and apparently you
    haven't created that correctly.I have checked the classpath and it seems to be ok
    The jar file ( axis.jar ) that I think is causing the error is included in the AXISCLASSPATH and in the CLASSPATH
    OS is Win XP
    the following errors remain -->
    java.lang.NoClassDefFoundError
         at org.apache.axis.client.Service.getAxisClient(Service.java:143)
         at org.apache.axis.client.Service.<init>(Service.java:152)
         at TempServelet.start1(TempServelet.java:72)
         at PostHTMLResult.fillArray(PostHTMLResult.java:65)
         at PostHTMLResult.doPost(PostHTMLResult.java:83)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    and 25 more errors
    I have checked the documnts for Tomcat 4.1 and axis for the setting the classpath , I dont know If there is a special setting I need to do ??
    Please advise
    Thanks
    IB

  • Sharing config with Servlet and Web Services

    Hi,
    I am building a Servlet wrapper and a jaxrpc wrapper for my application, so that my client can invoke either servlet or web services to access my application.
    my main application library is at WEB-INF/lib and both the servlet and
    webservices are in WEB-INF/classes.
    I am trying to make them sharing the same configuration file web.xml so that common attributes such as log file location can be read. I know Servlet can read the context and parameters but how to make my web services app to read it, since the web services are not servlet itself but it is invoked by the JAXRPC servlet????
    Thanks

    The early post may answer your question:
    http://forum.java.sun.com/thread.jsp?forum=331&thread=266102

  • PL/sql web service error !!!!!!! Help

    I was trying out the PL/SQL webservice example on OTN [http://otn.oracle.com/pub/articles/price_10gws.html]
    My environment is Oracle10G database, which comes with standalone version of oc4j, and I followed all the steps per the article but I still get the following error on invoking the Pl/SQL webservice: [What is the needed to make it work]...Please let me know...Thanks
    500 Internal Server Error
    java.lang.NoClassDefFoundError: oracle/aurora/ncomp/java/ClassNotFound
         at oracle.j2ee.ws.StatelessStoredProcRpcWebService.getGenerator(StatelessStoredProcRpcWebService.java:17)
         at oracle.j2ee.ws.RpcWebService.generateWrapperClass(RpcWebService.java:443)
         at oracle.j2ee.ws.RpcWebService.generate(RpcWebService.java:396)
         at oracle.j2ee.ws.RpcWebService.getWrapper(RpcWebService.java:514)
         at oracle.j2ee.ws.RpcWebService.doGetRequest(RpcWebService.java:613)
         at oracle.j2ee.ws.BaseWebService.doGet(BaseWebService.java:1117)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:733)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:484)
    My web.xml is:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
    <web-app>
    <servlet>
    <servlet-name>stateless Database web service - /plsqlsample/dbfunc</servlet-name>
    <servlet-class>oracle.j2ee.ws.StatelessStoredProcRpcWebService</servlet-class>
    <init-param>
    <param-name>class-name</param-name>
    <param-value>db.func.place.order.dbfuncUser</param-value>
    </init-param>
    <init-param>
    <param-name>interface-name</param-name>
    <param-value>db.func.place.order.dbfunc</param-value>
    </init-param>
    <init-param>
    <param-name>datasource-JNDI-name</param-name>
    <param-value>jdbc/OracleDSS</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>stateless Database web service - /plsqlsample/dbfunc</servlet-name>
    <url-pattern>/dbfunc</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    <resource-ref>
    <res-ref-name>jdbc/OracleDSS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>
    And under Directory C:\oracle\product\10.1.0\db01\oc4j\j2ee\home\applications\dbfunc\dbfunc_web\WEB-INF\classes\db\func\place\order
    I have
    08/01/2004 01:03 AM 264 dbfunc.class
    08/01/2004 01:06 AM 2,000 dbfunc.wsdl
    08/01/2004 01:03 AM 3,240 dbfuncBase.class
    08/01/2004 01:03 AM 694 dbfuncUser.class
    4 File(s) 6,198 bytes

    Hello!
    I have a question. You seem to be getting somewhere. In the reference (in your post) there is no mention of web.xml Is it a generated file or a file created by you? I am getting IOException error when generating EAR file. What could be wrong? Please help
    TAI
    habeeb

  • Help for mock web service (service skeleton and unmarshalling)

    Hi,
    I need to create mock web service in which I want to read soap/xml responses from my hard drive and send it to web service client. The responses would differ based on some input parameter. (small business logic in mock service)
    Till now, I created my mock service skeleton from Axis and used JAXB (JWSDP) to unmarshall xml to java objects. But problem is we can not cast object unmarshalled by JAXB into response object created by Axis. And so can not return those objects as response.
    So, I want to know if I can use JWSDP or Metro to solve this problem. Will JWSDP or Metro solve my problem if I use it to create service skeleton as well as for unmarshalling?
    If this is not possible, can you please suggest any viable alternative?
    Regards,
    Suraj

    surajmundada wrote:
    SOAP-UI can provide only one static soap response.Incorrect. Look at the [top 3 reasons|http://www.soapui.org/gettingstarted/mocking.html] from soap-ui. You can use Groovy to add the dynamic functionality in your simulated web service.
    And if you don't have the WSDL and you want to simulate the web service. You can use the article [web service simulation using servlet |http://today.java.net/article/2010/02/16/web-service-simulation-using-servlets] to build your own simulator.

Maybe you are looking for

  • Adobe Acrobat 9 STANDARD

    I have Product Activation Keys but I can't find the software for download.

  • Printer prints wrong colours after installing security update 6/2006

    Hello, I installed the last security update(006/2006) on my fathers imac running 10.3.9 and now the Printer, a Epson Stylus Color 740, prints pink when he schould print red and other colors are wrong too.Please help. thanx

  • Printing chat logs from an ipod touch???

    My daughter has an ipod touch and has downloaded Goober chat to her ipod. It does store chat logs is there any way these chat logs can be printed? If so please state directions in detail as I don't know how to use the ipod touch clearly. Thanks for a

  • A page web doesn't  work in safari

    hi! when i enter to my university page web in safari,http://www.lamolina.edu.pe/portada/, it doesn't look like internet explorer, the menu is in other side, behind other links, Why?

  • ESSBASE server - Connect Error 1042032:

    Hi All, I am having trouble connecting to Essbase Server on a new install i have done on a windows 2008 64 bit. The Installation went successful and I am able to start the essbase server from command prompt. From the Administration service Console, I