users@jaxb.java.net

How to consume CAML Formatted Response with JAXB?

From: lsacco <occasl_at_gmail.com>
Date: Wed, 2 Sep 2009 12:20:55 -0700 (PDT)

We would like to connect a Java Web services CXF client to the SharePoint
List service. After overcoming the NTLM issue, we see that the response is
not being properly unmarshalled by the client (it returns null). We used
the Maven cxf-codegen-plugin wsdl2java to create the client stub classes
that would represent the results but we get back NULL every time.

Here's the code to make the call and return the result (this all works
except for the return value is an empty list):

        public static GetListCollectionResult getListCollection(NTLMAuthenticator
auth, String endPoint) {
                Lists lists = new Lists();
                ListsSoap stub = lists.getListsSoap();

                BindingProvider bindProvider = (BindingProvider) stub;
                bindProvider.getRequestContext().put(
                                BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);
                Authenticator.setDefault(auth);
                setConduit(stub);
                return stub.getListCollection();
        }

Here is the sample output that repeats the List element that we can retrieve
using C#:

<Lists xmlns="http://schemas.microsoft.com/sharepoint/soap/">
        <List DocTemplateUrl="" DefaultViewUrl="/Lists/Audited Root Task
List/AllItems.aspx"
                MobileDefaultViewUrl="" ID="{AAAABEE6-CSDD-4C70-8AD0-567372066760}"
                Title="Audited Root Task List" Description=""
                ImageUrl="/_layouts/images/ittask.gif"
Name="{AAAABEE6-CSDD-4C70-8AD0-567372066760}"
                BaseType="0" FeatureId="00bfea71-a83e-497e-9ba0-7a5c597d0107"
                ServerTemplate="107" Created="20090805 06:31:27" Modified="20090818
06:09:13"
                LastDeleted="20090805 07:23:22" Version="35" Direction="none"
                ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="549457920"
                ItemCount="5" AnonymousPermMask="0" RootFolder="" ReadSecurity="1"
                WriteSecurity="1" Author="55" EventSinkAssembly="" EventSinkClass=""
                EventSinkData="" EmailInsertsFolder="" EmailAlias="" WebFullUrl="/"
                WebId="2bdcc5a2-563f-477c-b6d9-cf26c0067b36" SendToLocation=""
                ScopeId="ca78103c-95d7-4ffd-8cf1-77eb3b9a37ae" MajorVersionLimit="0"
                MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False"
                AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="True"
                EnableModeration="False" EnableVersioning="False" Hidden="False"
                MultipleDataList="False" Ordered="False" ShowUser="True"
                EnableMinorVersion="False" RequireCheckout="False" />
...

Here is the generated wsdl2java class for JAXB binding of the response:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "getListCollectionResult"
})
@XmlRootElement(name = "GetListCollectionResponse")
public class GetListCollectionResponse {

    @XmlElement(name = "GetListCollectionResult")
    protected GetListCollectionResponse.GetListCollectionResult
getListCollectionResult;

    public GetListCollectionResponse.GetListCollectionResult
getGetListCollectionResult() {
        return getListCollectionResult;
    }

    public void
setGetListCollectionResult(GetListCollectionResponse.GetListCollectionResult
value) {
        this.getListCollectionResult = value;
    }

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "content"
    })
    public static class GetListCollectionResult {

        @XmlMixed
        @XmlAnyElement(lax = true)
        protected List content;

        public List getContent() {
            if (content == null) {
                content = new ArrayList();
            }
            return this.content;
        }
    }
}

Any ideas on how to bind the CAML formatted output from the SP Web service
so the response can be unmarshalled properly by JAXB?

TIA!
Lou
-- 
View this message in context: http://www.nabble.com/How-to-consume-CAML-Formatted-Response-with-JAXB--tp25264026p25264026.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.