On Tuesday 06 April 2010 1:56:02 pm Naresh Bhatia wrote: > 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?
It's kind of a "best practice" for interopable web services, but it's also an important part of the JAX-WS specification. Section 2.3.1.2 of the JAX-WS spec goes into a lot of detail about when an operation is considered "wrapped doc/literal" or not. > 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? Nope. That's perfectly fine. Again, it would fall into the rules for wrapped doc/lit. (which, according to JAX-WS spec, is the default for code first scenarios) > 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? Since the default for a method like this in a code first scenario would be wrapped doc/lit, I would recommend just sticking with it. Dan > > 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
