4 Replies Latest reply on Aug 21, 2006 5:39 AM by Chris Knowles

    Example for transmitting a pojo

    Juergen Zimmermann Master

      Is there a working example on how to transmit a pojo from the server to the client? Any hint is highly appreciated!

      I'm using JBoss 4.0.4-Patch1 with EJB 3.0RC8_FD, JBossWS 1.0.2 and JSR-181 EJB endpoints with BASIC authentication.

      I'm struggling with the transmission of pojos. I use wstools to generate jaxrpc-mapping.xml and the wsdl file. The jaxrpc-mapping.xml file is on the CLASSPATH. However, I always get exceptions like:

      Call invocation failed: org.jboss.ws.binding.BindingException: org.jboss.ws.jaxb.UnmarshalException: Failed to parse source: Requested element {urn:mydomain}myproperty is not allowed in this position in the sequence. The next element should be myproperty; nested exception is: javax.xml.rpc.JAXRPCException: org.jboss.ws.binding.BindingException: org.jboss.ws.jaxb.UnmarshalException: Failed to parse source: Requested element {urn:mydomain}myproperty is not allowed in this position in the sequence. The next element should be myproperty


      BTW, I tried GLASSFISH to implement my client and had only a few problems. Is there no chance to use JBossWS for pojos? Actually I don't want to use two products...

        • 1. Re: Example for transmitting a pojo
          Thomas Diesler Master

          Juergen,

          JSR-181 is related to JAXWS and not JAXRPC. The jaxrpc-mapping file only applies to JAXRPC. The mapping in JAXWS is defined by JAXB annotations on the payload objects (i.e. your pojo)

          We provide JSR-181 functionality for trivial use cases that do not have special mapping requirements for bean properties.

          From the message you show above it seems that the property on the wire is namesapce qualified wheras jbossws expects it unqualified. Which one is right according to the abstract contract in wsdl + schema?

          • 2. Re: Example for transmitting a pojo
            Juergen Zimmermann Master

            Thomas,
            this is the beginning of the wsdl (via http://localhost:8080/jbossws) :

            <definitions name='KundenverwaltungService' targetNamespace='urn:hska' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:ns1='http://ws.hska.de/jaws' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='urn:hska' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
             <types>
             <schema elementFormDefault='qualified' targetNamespace='urn:hska' xmlns='http://www.w3.org/2001/XMLSchema' xmlns:ns2='http://ws.hska.de/jaws' xmlns:soap11-enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:tns='urn:hska' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
             <import namespace='http://ws.hska.de/jaws'/>
             <complexType name='KundeData'>
             <sequence>
             <element name='art' nillable='true' type='string'/>
             <element name='id' type='long'/>
             <element name='nachname' nillable='true' type='string'/>
             <element name='rabatt' type='int'/>
             <element name='vorname' nillable='true' type='string'/>
             </sequence>
             </complexType>


            I don't understand why my client complains about the properties. In my original posting just replace "urn:mydomain" with "urn:hska", and "myproperty" with "art".

            Any hint is appreciated.

            • 3. Re: Example for transmitting a pojo
              Chris Knowles Newbie

              I have a similar issue, but from client to server. I am using JBoss AS 4.0.4GA with JBoss WS 1.0.2GA and Easy SOAP on the client side. I have a company POJO that contains an address field. My test service is called HelloWorldService. My WSDL is strict, rpc literal with one way operations.

              16:19:40,429 ERROR [SOAPFaultExceptionHelper] SOAP request exception
              javax.xml.rpc.JAXRPCException: org.jboss.ws.binding.BindingException: org.jboss.ws.jaxb.UnmarshalException: Failed to parse source: Requeste
              d element {urn:HelloWorldService/wsdl}address is not allowed in this position in the sequence. The next element should be address
               at org.jboss.ws.soap.SOAPContentElement.getObjectValue(SOAPContentElement.java:292)
               at org.jboss.ws.binding.EndpointInvocation.transformPayloadValue(EndpointInvocation.java:233)
               at org.jboss.ws.binding.EndpointInvocation.getRequestParamValue(EndpointInvocation.java:103)
               at org.jboss.ws.binding.EndpointInvocation.getRequestPayload(EndpointInvocation.java:117)
               at org.jboss.ws.server.ServiceEndpointInvokerJSE.invokeServiceEndpoint(ServiceEndpointInvokerJSE.java:94)
               at org.jboss.ws.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:115)
               at org.jboss.ws.server.ServiceEndpoint.handleRequest(ServiceEndpoint.java:219)
               at org.jboss.ws.server.ServiceEndpointManager.processSOAPRequest(ServiceEndpointManager.java:355)
               at org.jboss.ws.server.StandardEndpointServlet.doPost(StandardEndpointServlet.java:115)
               at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
               at org.jboss.ws.server.StandardEndpointServlet.service(StandardEndpointServlet.java:76)
               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:96)
               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.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
               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:869)
               at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
               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:595)
              Caused by: org.jboss.ws.binding.BindingException: org.jboss.ws.jaxb.UnmarshalException: Failed to parse source: Requested element {urn:Hello
              WorldService/wsdl}address is not allowed in this position in the sequence. The next element should be address
               at org.jboss.ws.jaxrpc.encoding.JAXBDeserializer.deserialize(JAXBDeserializer.java:100)
               at org.jboss.ws.soap.SOAPContentElement.getObjectValue(SOAPContentElement.java:229)
               ... 29 more
              Caused by: org.jboss.ws.jaxb.UnmarshalException: Failed to parse source: Requested element {urn:HelloWorldService/wsdl}address is not allowe
              d in this position in the sequence. The next element should be address
               at org.jboss.ws.jaxb.JBossXBUnmarshallerImpl.unmarshal(JBossXBUnmarshallerImpl.java:67)
               at org.jboss.ws.jaxrpc.encoding.JAXBDeserializer.deserialize(JAXBDeserializer.java:92)
               ... 30 more
              Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: Requested element {urn:HelloWorldService/wsdl}address is not allow
              ed in this position in the sequence. The next element should be address
               at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:156)
               at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:126)
               at org.jboss.ws.jaxb.JBossXBUnmarshallerImpl.unmarshal(JBossXBUnmarshallerImpl.java:63)
               ... 31 more
              Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Requested element {urn:HelloWorldService/wsdl}address is not allowed in this positi
              on in the sequence. The next element should be address
               at org.jboss.xb.binding.sunday.unmarshalling.SequenceBinding$1.startElement(SequenceBinding.java:214)
               at org.jboss.xb.binding.sunday.unmarshalling.ModelGroupBinding$Cursor.startElement(ModelGroupBinding.java:152)
               at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:195)
               at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:301)
               at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
               at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
               at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
               at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
               at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
               at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
               at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
               at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
               at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
               at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:152)
               ... 33 more
              


              • 4. Re: Example for transmitting a pojo
                Chris Knowles Newbie

                I'm not sure if the namespace should or shouldn't be qualified. Here's the part of my wsdl corresponding to the function called that threw the above error. It may be a bug in the client code I'm using, but if its a bug in jboss, I'm unsure if its with jboss WS or jboss XB.

                <?xml version="1.0" encoding="UTF-8"?>
                <definitions name="HelloWorldService" targetNamespace="urn:HelloWorldService/wsdl"
                xmlns:tns="urn:HelloWorldService/wsdl"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:ns2="urn:HelloWorldService/types"
                xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                xmlns="http://schemas.xmlsoap.org/wsdl/">
                 <types>
                 <schema targetNamespace="urn:HelloWorldService/types"
                xmlns="http://www.w3.org/2001/XMLSchema"
                xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
                xmlns:tns="urn:HelloWorldService/types"
                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                 <complexType name="Company">
                 <sequence>
                 <element name="address" nillable="true" type="string"/>
                 <element name="id" nillable="true" type="int"/>
                 <element name="name" nillable="true" type="string"/>
                 </sequence>
                 </complexType>
                 </schema>
                 </types>
                 <message name="HelloWorldServiceSEI_updateCompany">
                 <part name="Company_1" type="ns2:Company"/>
                 </message>
                 <message name="HelloWorldServiceSEI_updateCompanyResponse">
                 <part name="result" type="xsd:boolean"/>
                 </message>
                 <portType name="HelloWorldServiceSEI">
                 <operation name="updateCompany" parameterOrder="Company_1">
                 <input message="tns:HelloWorldServiceSEI_updateCompany"/>
                 <output message="tns:HelloWorldServiceSEI_updateCompanyResponse"/>
                 </operation>
                 </portType>
                 <binding name="HelloWorldServiceSEIBinding" type="tns:HelloWorldServiceSEI">
                 <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
                 <operation name="updateCompany">
                 <soap:operation soapAction=""/>
                 <input>
                 <soap:body use="literal" namespace="urn:HelloWorldService/wsdl"/>
                 </input>
                 <output>
                 <soap:body use="literal" namespace="urn:HelloWorldService/wsdl"/>
                 </output>
                 </operation>
                 </binding>
                 <service name="HelloWorldService">
                 <port name="HelloWorldServiceSEIPort" binding="tns:HelloWorldServiceSEIBinding">
                 <soap:address location="http://localhost/EnterpriseApplication1-war/HelloWorldService"/>
                 </port>
                 </service>
                </definitions>