Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
JSP - A mailing list about Java Server Pages specification and reference
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
- Help in Setting up Servlet which receives/send

- Help in Setting up Servlet which receives/send

2007-07-11       - By helgravis

 Back
Hi, I'm fairly new in JBoss and I was wondering how to properly implement a
JAXMServlet.

Basically I needed a servlet which receives SOAP messages which is then passed
to some EJBs.

Here's my code, compiled with jaxm-api.jar and jboss-saaj.jar. The servlet just
receives a soap message, prints it out, and replies with a dummy soap message:

anonymous wrote : package com.app;
 |
 | import javax.servlet.ServletConfig Source code of javax.servlet.ServletConfig;
 | import javax.servlet.ServletException Source code of javax.servlet.ServletException;
 | import javax.xml.messaging.JAXMServlet;
 | import javax.xml.messaging.ReqRespListener;
 | import javax.xml.soap.*;
 |
 | public class SOAPServlet extends JAXMServlet implements ReqRespListener
 | {
 |   public SOAPServlet()
 |   {
 |   }
 |  
 |   public void init(ServletConfig config) throws ServletException
 |   {
 |     super.init(config);
 |   }
 |  
 |   public void destroy() {}
 |  
 |   public String getServletInfo()
 |   {
 |     return null;
 |   }
 |  
 |   public javax.xml.soap.SOAPMessage Source code of javax.xml.soap.SOAPMessage.html>javax.xml.soap.SOAPMessage Source code of javax.xml.soap.SOAPMessage javax.xml.soap.SOAPMessage Source code of javax.xml.soap.SOAPMessage.java.html>Source code of <a href=http://www.docjar.com/docs/api/javax/xml/soap/SOAPMessage.html>javax.xml.soap.SOAPMessage</a> <a href=http://www.docjar.com/html/api/javax/xml/soap/SOAPMessage.java.html><img src=/j.gif alt=' border=0> onMessage(javax.xml.soap.SOAPMessage Source code of javax.xml.soap.SOAPMessage.html>javax.xml.soap.SOAPMessage Source code of javax.xml.soap.SOAPMessage javax.xml.soap.SOAPMessage Source code of javax.xml.soap.SOAPMessage.java.html>Source code of <a href=http://www.docjar.com/docs/api/javax/xml/soap/SOAPMessage.html>javax.xml.soap.SOAPMessage</a> <a href=http://www.docjar.com/html/api/javax/xml/soap/SOAPMessage.java.html><img src=/j.gif alt=' border=0>
sOAPMessage)
 |   {
 |  
 |     System.out.println("Got a SOAP: "+sOAPMessage);
 |    
 |     SOAPMessage message = null;
 |    
 |     try
 |     {
 |       MessageFactory factory = MessageFactory.newInstance();
 |       message = factory.createMessage();
 |       SOAPPart soapPart = message.getSOAPPart();
 |       SOAPEnvelope envelope = soapPart.getEnvelope();
 |       SOAPBody body = envelope.getBody();
 |       Name bodyName = envelope.createName("Response");
 |  
 |       SOAPBodyElement gltp = body.addBodyElement(bodyName);
 |       Name nof = envelope.createName("blah");
 |      
 |       SOAPElement fileNumber = gltp.addChildElement(nof);
 |       fileNumber.addTextNode("123");
 |     }
 |     catch(Exception e)
 |     {
 |       System.out.println(e);
 |     }
 |    
 |     System.out.println("Returning message: "+message);
 |    
 |     return message;
 |   }
 | }

It compiles fine. But when I deployed it, it fired an error saying it couldn't
find javax.xml.messaging.ReqRespListener. I assumed that the current filepath
isn't finding the right classes, so what I did is dump the jaxm-api.jar in the
jbosshome/lib/endorsed folder. It filed an error saying it couldn't find
HttpServlet, so I added servlet-api.jar as well. Now the servlet deploys fine.

But whenever I try to send a SOAP using a SOAPClient, the servlet fires an
error saying:

anonymous wrote :
 | 11:38:04,872 ERROR [[soapentrypoint]] Servlet.service() for servlet
soapentrypoint threw exception
 | javax.servlet.ServletException Source code of javax.servlet.ServletException: JAXM POST failed setProperty must be
overridden by all subclasses of SOAPMessage
 |         at javax.xml.messaging.JAXMServlet.doPost(Unknown Source)
 |         at javax.servlet.http.HttpServlet Source code of javax.servlet.http.HttpServlet(HttpServlet.java:710)
 |         at javax.servlet.http.HttpServlet Source code of javax.servlet.http.HttpServlet(HttpServlet.java:803)
 |         at org.apache.catalina.core.ApplicationFilterChain Source code of org.apache.catalina.core.ApplicationFilterChain
(ApplicationFilterChain.java:290)
 |         at org.apache.catalina.core.ApplicationFilterChain Source code of org.apache.catalina.core.ApplicationFilterChain
(ApplicationFilterChain.java:206)
 |         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter
(ReplyHeaderFilter.java:96)
 |         at org.apache.catalina.core.ApplicationFilterChain Source code of org.apache.catalina.core.ApplicationFilterChain
(ApplicationFilterChain.java:235)
 |         at org.apache.catalina.core.ApplicationFilterChain Source code of org.apache.catalina.core.ApplicationFilterChain
(ApplicationFilterChain.java:206)
 |         at org.apache.catalina.core.StandardWrapperValve Source code of org.apache.catalina.core.StandardWrapperValve
(StandardWrapperValve.java:230)
 |         at org.apache.catalina.core.StandardContextValve Source code of org.apache.catalina.core.StandardContextValve
(StandardContextValve.java:175)
 |         at org.jboss.web.tomcat.security.SecurityAssociationValve Source code of org.jboss.web.tomcat.security.SecurityAssociationValve
(SecurityAssociationValve.java:179)
 |         at org.jboss.web.tomcat.security.JaccContextValve.invoke
(JaccContextValve.java:84)
 |         at org.apache.catalina.core.StandardHostValve Source code of org.apache.catalina.core.StandardHostValve
(StandardHostValve.java:128)
 |         at org.apache.catalina.valves.ErrorReportValve Source code of org.apache.catalina.valves.ErrorReportValve
(ErrorReportValve.java:104)
 |         at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke
(CachedConnectionValve.java:156)
 |         at org.apache.catalina.core.StandardEngineValve Source code of org.apache.catalina.core.StandardEngineValve
(StandardEngineValve.java:109)
 |         at org.apache.catalina.connector.CoyoteAdapter Source code of org.apache.catalina.connector.CoyoteAdapter
(CoyoteAdapter.java:241)
 |         at org.apache.coyote.http11.Http11Processor Source code of org.apache.coyote.http11.Http11Processor(Http11Processor
.java:844)
 |         at org.apache.coyote.http11.Http11Protocol Source code of org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler
.process(Http11Protocol.java:580)
 |         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint
.java:447)
 |         at java.lang.Thread Source code of java.lang.Thread(Thread.java:619)
 |
 |
Here's the SOAPClient code:

anonymous wrote : package com.app;
 |
 | import javax.xml.soap.*;
 |
 | import java.net.URL Source code of java.net.URL;
 |
 | public class SOAPsender
 | {
 |   public static void main(String[] args)  
 |   {
 |     try
 |     {            
 |       SOAPConnectionFactory soapConnectionFactory =
 |       SOAPConnectionFactory.newInstance();
 |       SOAPConnection connection = soapConnectionFactory.createConnection();
 |       SOAPFactory soapFactory = SOAPFactory.newInstance();
 |
 |       MessageFactory factory =
 |       MessageFactory.newInstance();
 |       SOAPMessage message = factory.createMessage();
 |
 |       SOAPHeader header = message.getSOAPHeader();
 |       SOAPBody body = message.getSOAPBody();
 |       header.detachNode();
 |
 |       Name bodyName = soapFactory.createName("asd");
 |       SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
 |
 |        Name name = soapFactory.createName("symbol");
 |        SOAPElement symbol = bodyElement.addChildElement(name);
 |        symbol.addTextNode("SUNW");
 |
 |        URL endpoint = new URL ("http://localhost:8080/SOAPServlet/soap");
 |        SOAPMessage response = connection.call(message, endpoint);
 |
 |        connection.close();
 |
 |        SOAPBody soapBody = response.getSOAPBody();
 |
 |       System.out.println(soapBody);
 |     }
 |     catch (Exception ex)
 |     {
 |       ex.printStackTrace();
 |     }
 |   }
 | }
 |

Please, can anyone tell me what I'm doing wrong? An asap reply is very much
appreciated, or maybe just a simple working .war example with all the necessary
jars packed in it?

I'm using jboss4.2.0, by the way.

Thank you very much

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic
&p=4063077#4063077

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode
=reply&p=4063077
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user

©2008 junlu.com - Jax Systems, LLC, U.S.A.