users@glassfish.java.net

How to annotate webmethod returning list of POJOs in GlassFish/alternatively: force GlassFish ORB to work through

From: Dmitriy Kuznetsov <heaven-seven_at_yandex.ru>
Date: Tue, 17 Feb 2009 04:17:40 -0800 (PST)

Hi,

i deploy a J2EE project with some @Stateless EJBs into GlassFish. The EJBs
have @Remote interfaces. They both are annotated as @WebService-s, e.g.

@Remote
@WebService
public interface BPMService {
        public List<StrictBlankStatusEntity> listBlankStatuses();
        public void persistStatus(AbstractStatusEntity status);
}

--- and ---

@Stateless
@WebService(endpointInterface="BPMService")
public class BPMServiceImpl implements BPMService {
    
        @Override
        public List<StrictBlankStatusEntity> listBlankStatuses() { ... }

        @Override
        public void persistStatus(AbstractStatusEntity status) { ... }
}

GlassFish v2.1 deploys them successfully, automatically generates WSDL doc
and Webservices.xml. I also have a hello-world-type client for this app,
built using Axis2:


        protected OMElement createPrayLoad() {
                OMFactory fac = OMAbstractFactory.getOMFactory();
                OMNamespace omNs =
fac.createOMNamespace("http://service.ib.cool/", "bpm");
                OMElement method = fac.createOMElement("listBlankStatuses",
omNs);
                return method;
        }


        protected void exec(){
                ServiceClient client;
                
                try {
                                  client = new ServiceClient(
                                null,
                                new
URL("http://localhost:8080/BPMServiceImplService/BPMServiceImpl?wsdl"),
                                null,
                                null);
                        OMElement res = client.sendReceive(new QName("http://service.ib.cool/",
"listBlankStatuses"), this.createPrayLoad());
                        System.out.println(res);
                } catch (Exception ex) {
                        // TODO Auto-generated catch block
                        ex.printStackTrace();
                }
        }

When i run the client, it says me (in console):

<ns2:listBlankStatusesResponse xmlns:ns2="http://service.ib.cool/">
    <return>
        <id>1</id><description>Some desc</description><name>New</name>
    </return>
    <return>
        <id>32768</id><description>Some other
desc</description><name>Received</name>
    </return>
</ns2:listBlankStatusesResponse>

so the webservice is accessible and does what it should do. The
StrictBlankStatusEntity POJO bean serialized into XML is a JPA @Entity class
with "id", "name" and "description" properties. Its defined near the EJBs.

Finally, the thing is that GlassFish-generated WSDL doc, as i can see:

<types>
<xsd:schema>
<xsd:import namespace="http://service.ib.cool/"
schemaLocation="http://localhost:8080/BPMServiceImplService/BPMServiceImpl?xsd=1"></xsd:import>
</xsd:schema>
</types>
<message name="listBlankStatuses">
<part name="parameters" element="tns:listBlankStatuses"></part>
</message>
<message name="listBlankStatusesResponse">
<part name="parameters" element="tns:listBlankStatusesResponse"></part>
</message>
<message name="persistStatus">
<part name="parameters" element="tns:persistStatus"></part>
</message>
<message name="persistStatusResponse">
<part name="parameters" element="tns:persistStatusResponse"></part>
</message>
<portType name="BPMService">
<operation name="listBlankStatuses">
<input message="tns:listBlankStatuses"></input>
<output message="tns:listBlankStatusesResponse"></output>
</operation>
<operation name="persistStatus">
<input message="tns:persistStatus"></input>
<output message="tns:persistStatusResponse"></output>
</operation>
</portType>
<binding name="BPMServiceImplPortBinding" type="tns:BPMService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"></soap:binding>
<operation name="listBlankStatuses">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
<operation name="persistStatus">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
</binding>
<service name="BPMServiceImplService">
<port name="BPMServiceImplPort" binding="tns:BPMServiceImplPortBinding">
<soap:address
location="http://localhost:8080/BPMServiceImplService/BPMServiceImpl"></soap:address>
</port>
</service>

contains nothing about the List<StrictBlankStatusEntity>, returned by
listBlankStatuses() method, defined in BPMService interface.

The questions are:
1. What and how should i annotate in my EJB project to force GlassFish to
generate WSDL doc, which includes information about
List<StrictBlankStatusEntity>, returned by listBlankStatuses() webmethod?
2. How should i force Axis2 to recognize the web method response?

I am absolute noob in webservices... I actually use them since i couldn't
force GlassFish-2.1-generated ORBs to work through NAT (i've enjoyed the 9
months old bug http://forums.java.net/jive/thread.jspa?messageID=217837) -
as a workaround. So, if you know, how to force GlassFish-generated-ORBs to
work with NAT properly, it would be much better for me, than webservices.
-- 
View this message in context: http://www.nabble.com/How-to-annotate-webmethod-returning-list-of-POJOs-in-GlassFish-alternatively%3A-force-GlassFish-ORB-to-work-through-tp22056028p22056028.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.