Argh.  I thought I replied to this weeks ago.  Trying again, as I still need 
help to get away from using RPC/encoded and use RPC/literal instead.

Service Endpoint interface:


  | package com.mycompany.tws;
  | 
  | import java.rmi.Remote;
  | import java.rmi.RemoteException;
  | import com.mycompany.enterprise.document.DocumentAccessException;
  | import com.mycompany.tws.document.DocumentBean;
  | 
  | public interface DocumentJse extends Remote {
  |     public String storeDocument(DocumentBean docBean) throws 
RemoteException, DocumentAccessException;
  | }
  | 


Service endpoint implementation:


  | package com.mycompany.tws;
  | 
  | import java.rmi.RemoteException;
  | import javax.xml.rpc.ServiceException;
  | import javax.xml.rpc.server.ServiceLifecycle;
  | import com.mycompany.enterprise.document.DocumentAccessException;
  | import com.mycompany.tws.document.DocumentBean;
  | 
  | public class DocumentJseImpl implements DocumentJse, ServiceLifecycle {
  |     
  |     private static final boolean FORCE_EXCEPTION = false;
  | 
  |     public DocumentJseImpl() {}
  |     public void init(Object arg0) throws ServiceException {}
  |     public void destroy() {}
  |     
  |     public String storeDocument(DocumentBean docBean) throws 
RemoteException, DocumentAccessException {
  |         System.out.println("DocumentJseImpl.storeDocument");
  |         if (FORCE_EXCEPTION) {
  |             System.out.println("  Throwing access exception.");
  |             throw new DocumentAccessException();
  |         }
  |         String[] docVals = docBean.getVals();
  |         for (int i=0; i<docVals.length; i++) {
  |             System.out.println("  docVals[" + i + "] = " + docVals);
  |         }
  |         return "Happy day.";
  |     }
  | }
  | 

DocumentBean transport object:


  | package com.mycompany.tws.document;
  | 
  | public final class DocumentBean {
  |     private String [] vals;
  |     public DocumentBean() {}
  |     public DocumentBean(String [] vals) { this.vals = vals; }   
  |     public String [] getVals() { return vals; }
  |     public void setVals(String [] vals) { this.vals = vals; }    
  | }
  | 

On the client side, we're doing things a bit strange with regard to registering 
serializers for the transport objects.  I know there is a JBoss specific 
implementation of ServiceFactory that takes a pointer to the JAX-RPC mapping 
file so that you don't have to manually register all the bean serializers and 
deserializers, but we need this client to work with web services deployed on 
WebLogic as well as on JBoss.  Here's the code on the client-side 
ServiceLocator:


  | package com.mycompany.twsc;
  | 
  | import java.net.MalformedURLException;
  | import java.net.URL;
  | import java.rmi.Remote;
  | import javax.xml.namespace.QName;
  | import javax.xml.rpc.Service;
  | import javax.xml.rpc.ServiceException;
  | import javax.xml.rpc.ServiceFactory;
  | import javax.xml.rpc.encoding.TypeMapping;
  | import javax.xml.rpc.encoding.TypeMappingRegistry;
  | import org.apache.axis.encoding.ser.BeanDeserializerFactory;
  | import org.apache.axis.encoding.ser.BeanSerializerFactory;
  | import com.mycompany.enterprise.ServiceUnavailableException;
  | import com.mycompany.tws.DocumentJse;
  | import com.mycompany.tws.document.DocumentBean;
  | 
  | public final class ServiceLocator {
  | 
  |     private static final String DOCUMENT_WSDL_URL = 
  |         "http://localhost:8080/wstesting/document?WSDL";;
  |     private static final String TWS_NS = 
  |         "http://tws.mycompany.com";;
  |     private static final String TWS_DOCUMENT_NS =
  |         "http://document.tws.mycompany.com";;    
  |     private static final QName TWS_SERVICE_QNAME = 
  |         new QName(TWS_NS, "Tws");
  |     private static final QName DOCUMENT_JSE_PORT_QNAME =
  |         new QName(TWS_NS, "DocumentJsePort");       
  |     
  |     /** The one and only instance of the locator. */
  |     private static final ServiceLocator INSTANCE = new ServiceLocator();
  |     
  |     /** A cached reference to the service factory. */
  |     private final ServiceFactory m_serviceFactory;
  |     
  |     // Override default constructor for non-instantiability.
  |     private ServiceLocator() {
  |             try {
  |                     m_serviceFactory = ServiceFactory.newInstance();
  |             } catch (ServiceException se) {
  |                     throw new RuntimeException(se);
  |             }
  |     }
  | 
  |     public static ServiceLocator getInstance() {return INSTANCE;}
  |     
  |     private void registerType(
  |             TypeMapping mapping, 
  |             String nameSpace, 
  |             String localName, 
  |             Class type) {
  |             QName qn = new QName(nameSpace, localName);
  |             mapping.register (
  |             type,
  |             qn,
  |             new BeanSerializerFactory(type, qn),
  |             new BeanDeserializerFactory(type, qn)
  |         );
  |     }
  |     
  |     /** 
  |      * Handles the common mechanics and exception handling involved with 
  |      * fetching a service port.
  |      * @param service the service
  |      * @param qn the qualified name of the service port
  |      * @param jse the class of the JSE interface to be fetched
  |      * @return a remote reference to the service port.
  |      */
  |     private Remote getServicePort(Service service, QName qn, Class jse) {
  |             
  |             try {
  |             return service.getPort(qn, jse);
  |             } catch (ServiceException se) {
  |                     // TODO log the exception?
  |                     System.out.println(se.getMessage());
  |                     se.printStackTrace();
  |                     return null;
  |             }
  |             
  |     }
  |     
  |     /**
  |      * Handles the common mechanics and exception handling involved with 
  |      * fetching a service endpoint.
  |      * @param wsdlUrl the URL of the WSDL for the service endpoint.
  |      * @param srvcName the qualifed name of the service endpoint.
  |      * @return a remote reference to the service.
  |      */
  |     private Service getService(String wsdlUrl, QName srvcName) 
  |     throws ServiceUnavailableException {
  | 
  |             Service srvc = null;
  |             try {
  |                     srvc = m_serviceFactory.createService(new URL(wsdlUrl), 
srvcName); 
  |             } catch (MalformedURLException mue) {
  |                     System.out.println(mue.getMessage());
  |                     mue.printStackTrace();
  |                     return null;
  |             } catch (ServiceException se) {
  |                 throw new ServiceUnavailableException(
  |                     "Service " + srvcName.toString() + " is unavailable.", 
se);
  |             }
  |             return srvc;
  |     }
  |     
  |     /**
  |      * Looks up the document service and returns a remote reference to it.
  |      * Also, configures type mappings with serializers and deserializers 
for 
  |      * each complex type passed to the service
  |      * API, or returned from it.
  |      * @return a remote reference to the document service.
  |      * @throws ServiceUnavailableException if connection cannot be made to 
svc
  |      */
  |     public DocumentJse getDocumentService() throws 
ServiceUnavailableException {
  | 
  |         DocumentJse docJse = null;
  |             Service docService = getService(DOCUMENT_WSDL_URL, 
TWS_SERVICE_QNAME);
  |         if (docService != null) {
  |             TypeMapping mapping = getTypeMapping(docService);
  |             registerType(mapping, TWS_DOCUMENT_NS, 
  |                     "DocumentBean", DocumentBean.class);
  |             docJse = (DocumentJse) getServicePort(docService, 
  |                     DOCUMENT_JSE_PORT_QNAME, DocumentJse.class);
  |         }
  |         return docJse;
  |     }
  | 
  |     private TypeMapping getTypeMapping(Service svc) {
  |         TypeMappingRegistry reg = svc.getTypeMappingRegistry(); 
  |         // For rpc/encoded...
  | //        return 
reg.getTypeMapping(reg.getRegisteredEncodingStyleURIs()[0]);
  |         // For rpc/literal...
  |         return reg.getDefaultTypeMapping();
  |     }
  | }
  | 


client-side interface:


  | package com.mycompany.tmsc;
  | 
  | import com.mycompany.enterprise.document.DocumentAccessException;
  | 
  | public interface TmsDocumentServices {
  |     public String storeDocument() throws DocumentAccessException;
  | }
  | 

client-side implementation:


  | package com.mycompany.twsc;
  | 
  | import java.rmi.RemoteException;
  | import com.mycompany.enterprise.ServiceUnavailableException;
  | import com.mycompany.enterprise.document.DocumentAccessException;
  | import com.mycompany.tmsc.TmsDocumentServices;
  | import com.mycompany.tws.DocumentJse;
  | import com.mycompany.tws.document.DocumentBean;
  | 
  | public class TmsDocumentServicesImpl implements TmsDocumentServices {       
  | 
  |     private DocumentJse m_documentService;
  |     
  |     public TmsDocumentServicesImpl() throws ServiceUnavailableException {
  |             m_documentService = 
ServiceLocator.getInstance().getDocumentService();
  |     }
  | 
  |     public String storeDocument() throws DocumentAccessException {
  |         String retval = null;
  | 
  |         DocumentBean docBean = new DocumentBean();
  |         docBean.setVals(new String[] { "phoebe" });
  | 
  |         try {
  |             retval = m_documentService.storeDocument(docBean);
  |         } catch (RemoteException re) {
  |             throw new RuntimeException(re);
  |         }
  |         return retval;
  |     }       
  | }
  | 

TestApp:


  | package com.mycompany.twsc;
  | 
  | import com.mycompany.enterprise.ServiceUnavailableException;
  | import com.mycompany.enterprise.document.DocumentAccessException;
  | import com.mycompany.tmsc.TmsDocumentServices;
  | 
  | public final class TestApp {
  | 
  |     private static TmsDocumentServices m_docSvc;
  |     
  |     public static void main(String[] args) {
  |         System.out.println("[INFO] Running TestApp.");
  |         try {
  |             m_docSvc = new TmsDocumentServicesImpl();
  |         } catch (ServiceUnavailableException e) {
  |             System.out.println("[ERROR] Document service is unavailable.");
  |             return;
  |         }
  |         
  |         System.out.println("[INFO] Calling storeDocument...");
  |         String retval = null;
  |         try {
  |             retval = m_docSvc.storeDocument();
  |         } catch (DocumentAccessException e) {
  |             System.out.println("[ERROR] Caught DocumentAccessException.");
  |         }
  |         System.out.println("[INFO] Back from storeDocument.  Returned value 
= " + retval);
  |     }
  | 
  | }
  | 

SOAP message:


  | <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  | <soapenv:Body>
  | <storeDocument xmlns="http://tws.mycompany.com";>
  | <DocumentBean_1 xmlns="">
  | <vals><item>phoebe</item></vals>
  | </DocumentBean_1>
  | </storeDocument>
  | </soapenv:Body>
  | </soapenv:Envelope>
  | 

Server error message:


  | 2005-12-02 13:07:41,073 DEBUG [org.jboss.axis.providers.java.RPCInvocation] 
There are 1 body elements.
  | 2005-12-02 13:07:41,073 DEBUG [org.jboss.axis.providers.java.RPCInvocation] 
body is [EMAIL PROTECTED]: null]]
  | 2005-12-02 13:07:41,073 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Pushing handler [EMAIL 
PROTECTED]
  | 2005-12-02 13:07:41,073 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Enter: 
DeserializationContextImpl::startPrefixMapping(, http://tws.mycompany.com)
  | 2005-12-02 13:07:41,073 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Exit: 
DeserializationContextImpl::startPrefixMapping()
  | 2005-12-02 13:07:41,073 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Enter: 
DeserializationContextImpl::startElement(http://tws.mycompany.com, 
storeDocument)
  | 2005-12-02 13:07:41,073 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Pushing handler [EMAIL 
PROTECTED]
  | 2005-12-02 13:07:41,073 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Exit: 
DeserializationContextImpl::startElement()
  | 2005-12-02 13:07:41,073 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Enter: 
DeserializationContextImpl::startElement(, DocumentBean_1)
  | 2005-12-02 13:07:41,073 DEBUG [org.jboss.axis.message.RPCHandler] Enter: 
RPCHandler.onStartChild()
  | 2005-12-02 13:07:41,073 DEBUG [org.jboss.axis.message.RPCHandler] Type from 
attributes is:  null
  | 2005-12-02 13:07:41,073 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Enter:getDeserializer: 
[class=class 
com.mycompany.tws.document.DocumentBean,xmlType={http://document.tws.mycompany.com}DocumentBean]
  | 2005-12-02 13:07:41,083 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Exit:getDeserializer: 
[EMAIL PROTECTED]
  | 2005-12-02 13:07:41,083 DEBUG [org.jboss.axis.message.RPCHandler] Exit: 
RPCHandler.onStartChild()
  | 2005-12-02 13:07:41,083 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Pushing handler [EMAIL 
PROTECTED]
  | 2005-12-02 13:07:41,083 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Exit: 
DeserializationContextImpl::startElement()
  | 2005-12-02 13:07:41,083 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Enter: 
DeserializationContextImpl::startElement(, vals)
  | 2005-12-02 13:07:41,083 DEBUG 
[org.jboss.axis.encoding.ser.BeanDeserializer] onStartChild: vals
  | 2005-12-02 13:07:41,083 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Enter:getDeserializer: 
[class=class 
[Ljava.lang.String;,xmlType={http://schemas.xmlsoap.org/soap/encoding/}Array]
  | 2005-12-02 13:07:41,083 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Exit:getDeserializer: null
  | 2005-12-02 13:07:41,083 DEBUG 
[org.jboss.axis.encoding.ser.BeanDeserializer] Using itemXmlType = 
{http://www.w3.org/2001/XMLSchema}string
  | 2005-12-02 13:07:41,083 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Enter:getDeserializer: 
[class=class java.lang.String,xmlType={http://www.w3.org/2001/XMLSchema}string]
  | 2005-12-02 13:07:41,103 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Exit:getDeserializer: 
[EMAIL PROTECTED]
  | 2005-12-02 13:07:41,103 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Pushing handler [EMAIL 
PROTECTED]
  | 2005-12-02 13:07:41,103 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Exit: 
DeserializationContextImpl::startElement()
  | 2005-12-02 13:07:41,103 DEBUG 
[org.jboss.axis.encoding.DeserializationContextImpl] Enter: 
DeserializationContextImpl::startElement(, item)
  | 2005-12-02 13:07:41,103 ERROR [org.jboss.axis.providers.java.RPCInvocation] 
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which 
is NOT expected, in something it was trying to deserialize.
  | org.xml.sax.SAXException: SimpleDeserializer encountered a child element, 
which is NOT expected, in something it was trying to deserialize.
  |     at 
org.jboss.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:206)
  |     at 
org.jboss.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:1168)
  |     at 
org.jboss.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:244)
  |     at 
org.jboss.axis.message.SOAPElementAxisImpl.publishToHandler(SOAPElementAxisImpl.java:1386)
  |     at org.jboss.axis.message.RPCElement.deserialize(RPCElement.java:262)
  |     at org.jboss.axis.message.RPCElement.getParams(RPCElement.java:396)
  |     at 
org.jboss.axis.providers.java.RPCInvocation.prepareFromRequestEnvelope(RPCInvocation.java:235)
  |     at 
org.jboss.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:103)
  |     at 
org.jboss.axis.providers.java.JavaProvider.invoke(JavaProvider.java:358)
  |     at 
org.jboss.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:73)
  |     at org.jboss.axis.SimpleChain.doVisiting(SimpleChain.java:160)
  |     at org.jboss.axis.SimpleChain.invoke(SimpleChain.java:123)
  |     at org.jboss.axis.handlers.soap.SOAPService.invoke(SOAPService.java:560)
  |     at 
org.jboss.webservice.server.ServerEngine.invokeInternal(ServerEngine.java:200)
  |     at org.jboss.webservice.server.ServerEngine.invoke(ServerEngine.java:89)
  |     at 
org.jboss.axis.transport.http.AxisServlet.doPost(AxisServlet.java:905)
  |     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  |     at 
org.jboss.axis.transport.http.AxisServletBase.service(AxisServletBase.java:370)
  |     at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |     at 
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |     at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |     at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
  |     at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
  |     at 
org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
  |     at 
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
  |     at 
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
  |     at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
  |     at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  |     at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
  |     at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  |     at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
  |     at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
  |     at 
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  |     at 
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
  |     at java.lang.Thread.run(Thread.java:534)
  | 


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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3913016


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to