I did quite a bit of goggling to answer #2. It looks like my use case is really not a "document" use case. I am essentially using the web service as an RPC mechanism - to populate various screens of my thick-client - so GetAccountSummaries() is simply used to display account summaries on the front-end. This is probably the best post I found on differentiating between document vs. RPC usage:
http://www.coderanch.com/t/443021/Web-Services-Certification-SCDJWS/certification/Difference-between-RPC-Document-web#1971102 In this post, the document example is of submitting a purchase order, whereas the RPC example is of getting a book price. It also appears that I can implement either "style" using a document/literal web service - the only difference is how I think about the problem. I would appreciate any thoughts on this subject. Thanks. Naresh -----Original Message----- From: Naresh Bhatia Sent: Tuesday, April 06, 2010 1:56 PM To: [email protected] Subject: RE: wsdl2java - creating List return type Thanks Dan - that works great! I have couple of follow-up questions: 1) Is this (i.e. element names must match the operation name) just a convention that wsdl2java uses or is it part of some best practice or a standard? 2) What I am trying to do, i.e. return a List<AccountSummary> - would that be considered a bad practice based on document/literal approach? Is this too RPC like and a better approach would be to indeed return an element called AccountSummaries which would encapsulate a list of AccountSummary objects? Thanks. Naresh -----Original Message----- From: Daniel Kulp [mailto:[email protected]] Sent: Tuesday, April 06, 2010 1:07 PM To: [email protected] Cc: Naresh Bhatia Subject: Re: wsdl2java - creating List return type On Monday 05 April 2010 8:42:21 am Naresh Bhatia wrote: > Still not working. This is what I am getting now: > > public AccountSummariesResponse getAccountSummaries( > AccountSummaries accountSummaries); > > Not only is the result wrapped, I am also getting a parameter that's not > needed. My bad. The element names must match the operation name. Thus, the element names would be: GetAccountSummaries and GetAccountSummariesResponse Dan > > Here's the modified wsdl (I think I got everything you suggested): > > <definitions > targetNamespace="http://myapp.org/account.wsdl" > xmlns="http://schemas.xmlsoap.org/wsdl/" > xmlns:acnt="http://myapp.org/account.xsd" > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" > xmlns:tns="http://myapp.org/account.wsdl"> > > <types> > <xsd:schema > targetNamespace="http://myapp.org/account.xsd" > elementFormDefault="qualified" > xmlns:tns="http://myapp.org/account.xsd" > xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > > <xsd:element name="AccountSummaries"> > <xsd:complexType> > <xsd:sequence /> > </xsd:complexType> > </xsd:element> > > <xsd:element name="AccountSummariesResponse" > type="tns:AccountSummariesResponse" /> > > <xsd:complexType name="AccountSummariesResponse"> > <xsd:sequence> > <xsd:element name="AccountSummary" > type="tns:AccountSummary" minOccurs="0" maxOccurs="unbounded" /> > </xsd:sequence> > </xsd:complexType> > > <xsd:complexType name="AccountSummary"> > <xsd:sequence> > <xsd:element name="id" type="xsd:long" /> > <xsd:element name="cash" type="xsd:decimal" /> > </xsd:sequence> > </xsd:complexType> > > </xsd:schema> > </types> > > <message name="AccountSummariesRequest"> > <part name="AccountSummaries" element="acnt:AccountSummaries" /> > </message> > > <message name="AccountSummariesResponse"> > <part name="AccountSummariesResponse" > element="acnt:AccountSummariesResponse" /> </message> > > <portType name="AccountProvider"> > <operation name="GetAccountSummaries"> > <input message="tns:AccountSummariesRequest" /> > <output message="tns:AccountSummariesResponse" /> > </operation> > </portType> > > <binding name="AccountBinding" type="tns:AccountProvider"> > <soap:binding style="document" > transport="http://schemas.xmlsoap.org/soap/http" /> <operation > name="GetAccountSummaries"> > <soap:operation soapAction="GetAccountSummaries" /> > <input> > <soap:body use="literal" /> > </input> > <output> > <soap:body use="literal" /> > </output> > </operation> > </binding> > > <service name="AccountService"> > <port name="AccountPort" binding="tns:AccountBinding"> > <soap:address > location="http://localhost:8080/myapp/services/account" /> </port> > </service> > > </definitions> > > Thanks. > Naresh > > -----Original Message----- > From: Daniel Kulp [mailto:[email protected]] > Sent: Monday, April 05, 2010 2:27 AM > To: [email protected] > Cc: Naresh Bhatia > Subject: Re: wsdl2java - creating List return type > > > 1) Change the AccountSummaries element name to AccountSummariesResponse. > > 2) Create a new AccountSummaries element that is a empty sequence > complexType. > > 3) Change the AccountSummariesRequest message to contain a single part that > points at that new element. > > > Dan > > On Monday 05 April 2010 12:53:47 am Naresh Bhatia wrote: > > I am trying to write an operation in WSDL that returns a list. > > Essentially, > > > > I want wsdl2java to generate the following method for me: > > public List<AccountSummary> getAccountSummaries(); > > > > How do I do this? I tried different things, but I always end up with > > wsdl2java creating a wrapper over the list and returning this wrapper, > > e.g. > > > > public AccountSummaries getAccountSummaries(); > > > > where AccountSummaries wraps a List<AccountSummary>. > > > > Here's my WSDL. Can someone show me how to change it so that the > > getAccountSummaries() method returns an unwrapped list? > > > > <definitions > > > > targetNamespace="http://myapp.org/account.wsdl" > > xmlns="http://schemas.xmlsoap.org/wsdl/" > > xmlns:acnt="http://myapp.org/account.xsd" > > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" > > xmlns:tns="http://myapp.org/account.wsdl"> > > > > <types> > > > > <xsd:schema > > > > targetNamespace="http://myapp.org/account.xsd" > > elementFormDefault="qualified" > > xmlns:tns="http://myapp.org/account.xsd" > > xmlns:xsd="http://www.w3.org/2001/XMLSchema"> > > > > <xsd:element name="AccountSummaries" > > > > type="tns:AccountSummaries" /> > > > > <xsd:complexType name="AccountSummaries"> > > > > <xsd:sequence> > > > > <xsd:element name="AccountSummary" > > > > type="tns:AccountSummary" minOccurs="0" maxOccurs="unbounded" /> > > > > </xsd:sequence> > > > > </xsd:complexType> > > > > <xsd:complexType name="AccountSummary"> > > > > <xsd:sequence> > > > > <xsd:element name="id" type="xsd:long" /> > > <xsd:element name="cash" type="xsd:decimal" /> > > > > </xsd:sequence> > > > > </xsd:complexType> > > > > </xsd:schema> > > > > </types> > > > > <message name="AccountSummariesRequest" /> > > > > <message name="AccountSummariesResponse"> > > > > <part name="AccountSummaries" element="acnt:AccountSummaries" /> > > > > </message> > > > > <portType name="AccountProvider"> > > > > <operation name="GetAccountSummaries"> > > > > <input message="tns:AccountSummariesRequest" /> > > <output message="tns:AccountSummariesResponse" /> > > > > </operation> > > > > </portType> > > > > <binding name="AccountBinding" type="tns:AccountProvider"> > > > > <soap:binding style="document" > > > > transport="http://schemas.xmlsoap.org/soap/http" /> <operation > > name="GetAccountSummaries"> > > > > <soap:operation soapAction="GetAccountSummaries" /> > > <input> > > > > <soap:body use="literal" /> > > > > </input> > > <output> > > > > <soap:body use="literal" /> > > > > </output> > > > > </operation> > > > > </binding> > > > > <service name="AccountService"> > > > > <port name="AccountPort" binding="tns:AccountBinding"> > > > > <soap:address > > > > location="http://localhost:8080/myapp/services/account" /> </port> > > > > </service> > > > > </definitions> > > > > > > Thanks. > > Naresh -- Daniel Kulp [email protected] http://dankulp.com/blog
