Dan,

You were right, Set is handled transparently (java.util.Set isn't in the WSDL as I thought it was... I'm not sure where I got that idea actually). The problem was I had:

public void setKeywords( final Collection<String> newKeywords )
public Set<String> getKeywords()

The types were different, so the javabeans properties didn't recognize setKeywords as the setter method, and told XFire the property wasn't writeable. Once I changed the setter to use Set<String> as well, it was able to set the keywords property without issue.

public void setKeywords( final Set<String> newKeywords )

Thanks for that. I may have additional questions when I try to use the Set of Authors, but we'll see how that goes now that I've got this working.

Mark

On Apr 18, 2006, at 5:22 PM, Dan Diephouse wrote:

Hi Mark,

Mark Slater wrote:

I've got a service that needs to send two types of arrays to the XFire-based server and I'm trying to figure out why I can't seem to be able to un-marshal the array. One array is of Strings, the other array is of a complex type called Author.

I've got the required bean property setters for the Keyword array:

    public void setKeywords( final int index, final String keyword )
    public void setKeywords( final Collection<String> newKeywords )
    public void setKeywords( final String[] newKeywords )

You should only need one setter and I'm not 100% sure how the javabean stuff works offhand, but I think that more than one is likely to confuse it. So if you're getter is "Collection<String> getKeywords()" your setter should be "setKeywords (Collection<String> keywords)".


And as a side note, I found that XFire was completely unable to set the keywords property when the setKeywords( int, String) method didn't exist. It would be nice if that method didn't need to be there because the Keywords property is actually a Set (unordered).

I don't know how that extra method would change things at all. XFire won't recognize any such method.

I pass it as an array over the SOAP to avoid having extra WSDL about the Set class. If there's a better way to do this, I'd love to know it.

If you declare the property as a Set<String> type XFire should pick that up no problem and be able to construct the wsdl accordingly. This isn't like Axis where you need to use Arrays.


But back to my current problem: the keywords are not being set. I know XFire is able to set them because before I added all three of the setKeyword methods above, I was getting a fault saying that the property wasn't writable. The first thing I do in the addItemToLibrary() method is print the new item, and the keywords are not present. I've added logging code to the LibraryItemInfoData class which registers the simple string primaryKeyword being set, but does not register any of the setKeywords() methods being called.

What am I missing in this invocation?

I would just simplify to one getter and one setter and see if you can get it to work. It looks like your wsdl is right below, but maybe the extras are confusing xfire somehow? I'm not sure though.

Thanks!

Mark

-----------

The relevant WSDL is:

      <xsd:complexType name="LibraryItemInfoData">
        <xsd:sequence>
<xsd:element name="UUID" type="xsd:string" nillable="true" /> <xsd:element name="authors" type="ns1:ArrayOfAuthor" nillable="true" />
          <xsd:element name="dateCreated" type="xsd:dateTime" />
          <xsd:element name="dateEntered" type="xsd:dateTime" />
<xsd:element name="encoding" type="xsd:string" nillable="true" /> <xsd:element name="keywords" type="tns:ArrayOfString" nillable="true" />
          <xsd:element name="lastModified" type="xsd:dateTime" />
<xsd:element name="mimeType" type="xsd:string" nillable="true" /> <xsd:element name="primaryKeyword" type="xsd:string" nillable="true" />
          <xsd:element name="size" type="xsd:long" />
<xsd:element name="title" type="xsd:string" nillable="true" /> <xsd:element name="typeExtension" type="xsd:string" nillable="true" /> <xsd:element name="username" type="xsd:string" nillable="true" /> <xsd:element name="whisperId" type="xsd:string" nillable="true" />
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ArrayOfAuthor">
        <xsd:sequence>
<xsd:element name="Author" type="ns1:Author" nillable="true" minOccurs="0" maxOccurs="unbounded" />
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="Author">
        <xsd:sequence>
<xsd:element name="familyName" type="xsd:string" nillable="true" /> <xsd:element name="firstName" type="xsd:string" nillable="true" /> <xsd:element name="fullName" type="xsd:string" nillable="true" /> <xsd:element name="organizationName" type="xsd:string" nillable="true" /> <xsd:element name="otherNames" type="xsd:string" nillable="true" />
          <xsd:element name="person" type="xsd:boolean" />
<xsd:element name="username" type="xsd:string" nillable="true" />
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ArrayOfString">
        <xsd:sequence>
<xsd:element name="string" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded" />
        </xsd:sequence>
      </xsd:complexType>

-----------

The message going to the server is:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/ soap/ envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:ns4="http://rpc.whisper.ucsc.edu";
xmlns:ns5="http://core.whisper.ucsc.edu";
>
<SOAP-ENV:Header>
...
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns4:addItemToLibrary>
<in0>
<ns5:dateCreated>2006-02-04T00:00:00-08:00</ns5:dateCreated>
<ns5:primaryKeyword>Directions</ns5:primaryKeyword>
<ns5:title>Directions</ns5:title>
<ns5:keywords>
<ns4:string>stephen</ns4:string>
<ns4:string>alameda</ns4:string></ns5:keywords></in0>
</ns4:addItemToLibrary>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>



--
Dan Diephouse
(616) 971-2053
Envoi Solutions LLC
http://netzooid.com




Reply via email to