3 Replies Latest reply on Jan 3, 2007 6:49 AM by Marco

    J2ME/JBossws 1.0.3 / chunking disabled but still error

    Marco Novice

      hi all,
      i m fighting trying to have myJ2ME cdlient to communicate iwht my EJB3 Webservice..
      i noticed posts about http chunking, so i have disabled http chunking by setting this in deploy/tomcat/server.xml


      this is the interface of my WS

      /**
       * Copyright @ 2006
       * By Marco Mistroni
       * Session EJB test
       */
      package com.mm.j2me.ejb;
      
      import java.util.Date;
      import java.util.List;
      
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.jws.WebService;
      import javax.jws.WebMethod;
      import javax.jws.WebParam;
      import javax.jws.WebResult;
      import javax.jws.soap.SOAPBinding;
      
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      import javax.persistence.Query;
      
      import org.jboss.annotation.ejb.RemoteBinding;
      //import org.jboss.ws.annotation.PortComponent;
      
      import com.mm.j2me.core.Agency;
      import com.mm.j2me.core.JobApplication;
      import com.mm.j2me.core.Opportunity;
      import com.mm.j2me.core.User;
      import com.mm.j2me.core.WSFacade;
      
      @WebService (name="WSRemoteSEI",
       serviceName="WSFacade",
       targetNamespace="http://org.jboss.ws/ejb3ws")
      @SOAPBinding(style = SOAPBinding.Style.DOCUMENT,
       use=SOAPBinding.Use.LITERAL)
      
      
      @Stateless
      @Remote (WSFacade.class)
      @RemoteBinding( jndiBinding="/ejb3/WSRemoteSEI")
      
      public class TestFacade implements WSFacade{
      
       @PersistenceContext
       EntityManager em;
       public void deleteAgency(Agency agency) {
       // TODO Auto-generated method stub
       Query query = getQuery("findAgencyById");
       query.setParameter("id", agency.getId());
       Agency agencyToDelete = (Agency)query.getSingleResult();
       em.remove(agencyToDelete);
       }
      
       public void deleteJobApplication(JobApplication app) {
       Query query = getQuery("findJAById");
       query.setParameter("id", app.getId());
       JobApplication jaToDelete = (JobApplication)query.getSingleResult();
       em.remove(jaToDelete);
      
       }
      
       public void deleteOpportunity(Opportunity opp) {
       Query query = getQuery("findOpportunityById");
       query.setParameter("id", opp.getId());
       Opportunity oppToDelete = (Opportunity)query.getSingleResult();
       em.remove(oppToDelete);
      
       }
      
       public Agency[] getAllAgencies() {
       // TODO Auto-generated method stub
       Query query = getQuery("findAllAgencies");
       List<Agency> list = query.getResultList();
       Agency[] agencies = new Agency[list.size()];
       return (Agency[])(list.toArray(agencies));
       }
      
       public JobApplication[] getAllJobApplications() {
       return new JobApplication[]{};
       }
      
       public Opportunity[] getAllOpportunities() {
       //Query query = getQuery("findAllOpportunities");
       //return query.getResultList();
       return new Opportunity[]{};
       }
      
       public void insertAgency(Agency agency) {
       // TODO Auto-generated method stub
       em.persist(agency);
       }
      
       public void insertJobApplication(JobApplication app) {
       em.persist(app);
      
       }
      
       public void insertOpportunity(Opportunity opp) {
       em.persist(opp);
      
       }
      
      
      
       private Query getQuery(String name) {
       return em.createNamedQuery(name);
       }
      
      
       @WebMethod(action="urn:synchronizeAgency")
       public @WebResult(name="returnAgency")Agency[]
       synchronizeAgency(@WebParam(name="inAgency")Agency[] inAgency) {
       Agency[] agencies = new Agency[2];
       Agency ag = new AgencyEEjb();
       ag.setName("ag1");
       ag.setEmailAddress("test@email.com");
       ag.setJobHunter("fuckya");
       ag.setPhoneNumber("1234");
       ag.setSite("mysite");
       agencies[0] = ag;
       Agency ag2 = new AgencyEEjb();
       ag2.setName("ag2");
       ag2.setEmailAddress("t@email.com");
       ag2.setJobHunter("f222");
       ag2.setPhoneNumber("122222");
       ag2.setSite("mysite222");
       agencies[1] = ag2;
       return agencies;
       }
      
       @WebMethod(action="urn:synchronizeJobApplication")
       public @WebResult(name="returnJA")JobApplication[]
       synchronizeJobApplication( @WebParam(name="inJA")JobApplication[] inJA) {
       JobApplication[] jas = new JobApplication[2];
       JobApplication ja1 = new JobApplicationEEjb();
       ja1.setAgencyName("Pathway");
       ja1.setCompany("Sumitomo Bank");
       ja1.setDuration(6);
       ja1.setJobApplicationTitle("Tester");
       ja1.setLocation("Reading");
       ja1.setSalary("300/day");
       jas[0] = ja1;
       JobApplication ja2 = new JobApplicationEEjb();
       ja2.setAgencyName("Mann");
       ja2.setCompany("Lehman Brothers");
       ja2.setDuration(6);
       ja2.setJobApplicationTitle("Sw Engineer");
       ja2.setLocation("London");
       ja2.setSalary("400/day");
       jas[1] = ja2;
       return jas;
       }
      
      
       @WebMethod(action="urn:synchronizeOpportunity")
       public @WebResult(name="returnOpportunity")Opportunity[]
       synchronizeOpportunity(@WebParam(name="inOpp")Opportunity[] inOpp) {
       Opportunity[] opps = new Opportunity[2];
       Opportunity opps1 = new OpportunityEEjb();
       opps1.setAgencyName("IT People");
       opps1.setJobHunterName("Syed Ahmed");
       opps1.setOpportunityDetails("SW Engineer in London");
       opps1.setOpportunityDate(new Date().getTime());
       opps1.setOpportunityEmail("mm@tgmm.com");
       opps[0] = opps1;
       Opportunity opps2 = new OpportunityEEjb();
       opps2.setAgencyName("Computer People");
       opps2.setJobHunterName("Menachim Begin");
       opps2.setOpportunityDetails("SW Engineer in France");
       opps2.setOpportunityDate(new Date().getTime());
       opps2.setOpportunityEmail("mm@tgmm.com");
       opps[1] = opps2;
      
       return opps;
       }
      
       @WebMethod(action="urn:login")
       public void login(@WebParam(name="username")String user,
       @WebParam(name="password")String password) {
       System.err.println("----- loggging in.....");
      
       }
      
       // Original sample
       @WebMethod(action="urn:testWebServiceMethod")
       public @WebResult(name="returnAgency")Agency[]
       testWebServiceMethod( @WebParam(name="inAgency") Agency[] inAgency) {
      
       Agency[] agencies = new Agency[2];
       Agency ag = new AgencyEEjb();
       ag.setName("ag1");
       ag.setEmailAddress("test@email.com");
       ag.setJobHunter("fuckya");
       ag.setPhoneNumber("1234");
       ag.setSite("mysite");
       agencies[0] = ag;
       Agency ag2 = new AgencyEEjb();
       ag2.setName("ag2");
       ag2.setEmailAddress("t@email.com");
       ag2.setJobHunter("f222");
       ag2.setPhoneNumber("122222");
       ag2.setSite("mysite222");
       agencies[1] = ag2;
       return agencies;
       }
      
       public void storeAgency(Agency agency) {
       // TODO Auto-generated method stub
      
       }
      
       public void storeJobApplication(JobApplication ja) {
       // TODO Auto-generated method stub
      
       }
      
       public void storeOpportunity(Opportunity opp) {
       // TODO Auto-generated method stub
      
       }
      }
      


      i am testing the login method (which returns void)

      this is the response that my j2me client gets

      <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
      <env:Header/>
      <env:Body><ns1:loginResponse xmlns:ns1='http://org.jboss.ws/ejb3ws' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'/>
      </env:Body>
      </env:Envelope>
      



      still, i am getting this exception from midp

      AXRPcC EXception.
      javax.xml.rpc.JAXRPCException: java.rmi.MarshalException: (1)Missing end tag for Body or Envelope
       at com.sun.j2mews.xml.rpc.SOAPDecoder.decode(+243)
       at com.sun.j2mews.xml.rpc.OperationImpl.invoke(+90)
       at com.mm.j2me.ws.WSRemoteSEI_Stub.login(+48)
       at com.mm.j2me.midp.model.HTTPCommunicationHandler.createAccount(+36)
       at com.mm.j2me.midp.model.RemoteModelRequestHandler.createAccount(+16)
       at com.mm.j2me.midp.model.RemoteModelProxy.createAccount(+16)
       at com.mm.j2me.midp.model.ModelFacade.createAccount(+16)
       at com.mm.j2me.midp.ui.UIController$EventDispatcher.run(+277)
      


      can anyone help pls? i have been stuck with this for 4 days....

      thanks and regards
      marco

        • 1. Re: J2ME/JBossws 1.0.3 / chunking disabled but still error
          Heiko Braun Master

          You should try the service endpoint with a different client and verify that it works. You could use SOAPUI to do that (http://www.soapui.org/).

          This would help isolating the problem.

          • 2. Re: J2ME/JBossws 1.0.3 / chunking disabled but still error
            Marco Novice

            Hello,
            ok i followed suggestion given by heiko..
            downloaded SOAPUI... run it... response is this

            <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
             <env:Header/>
             <env:Body>
             <ns1:loginResponse xmlns:ns1="http://org.jboss.ws/ejb3ws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
             <ns1:logged>foobar</ns1:logged>
             </ns1:loginResponse>
             </env:Body>
            </env:Envelope>
            


            which is, except for doublequotes instead of singlequotes, exactly same as the one received by WTK client
            <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
             <env:Header/>
             <env:Body>
             <ns1:loginResponse xmlns:ns1='http://org.jboss.ws/ejb3ws' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
             <ns1:logged>foobar</ns1:logged>
             </ns1:loginResponse>
             </env:Body>
            </env:Envelope>
            


            So, i decided to use axis 1.4 to write a client for my webservice...
            i did it and it worked just fine...

            so final conclusion is....... WTK is bugged, at least with regard to WebServices invocation..
            I am going to try Nokia toolkit, and see if i have better luck....

            thanks and regards
            Marco

            • 3. Re: J2ME/JBossws 1.0.3 / chunking disabled but still error
              Marco Novice

              Nope
              No luck

              Nokia's carbide.j stub creation is screwed up big time.. at least for my WS which is not a simple HelloWorld webservice..

              i think i'll go for some J2ME SOAP packages or back to kXML/kSOAP... if anyone has any suggestion, they are all welcome..

              thanks and regards
              marco