  | 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
|
|
|
  | | | - 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 ; | import 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 .html>javax.xml.soap.SOAPMessage javax.xml.soap.SOAPMessage .java.html> ' border=0> onMessage(javax.xml.soap.SOAPMessage .html>javax.xml.soap.SOAPMessage javax.xml.soap.SOAPMessage .java.html> ' 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 : 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 (HttpServlet.java:710) | at javax.servlet.http.HttpServlet (HttpServlet.java:803) | at org.apache.catalina.core.ApplicationFilterChain  (ApplicationFilterChain.java:290) | at 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  (ApplicationFilterChain.java:235) | at org.apache.catalina.core.ApplicationFilterChain  (ApplicationFilterChain.java:206) | at org.apache.catalina.core.StandardWrapperValve  (StandardWrapperValve.java:230) | at org.apache.catalina.core.StandardContextValve  (StandardContextValve.java:175) | at 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  (StandardHostValve.java:128) | at 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  (StandardEngineValve.java:109) | at org.apache.catalina.connector.CoyoteAdapter  (CoyoteAdapter.java:241) | at org.apache.coyote.http11.Http11Processor (Http11Processor .java:844) | at 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 (Thread.java:619) | | Here's the SOAPClient code:
anonymous wrote : package com.app; | | import javax.xml.soap.*; | | import 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
|
|
 |