SharePoint列表服务递归不起作用

时间:2009-11-17 22:30:21

标签: sharepoint

我使用以下代码检索列表中的文档。它的工作正常。但是,它只返回文档库根目录中的文档和文件夹。我在这里做错了吗?我正在寻找具有递归模式的子文件夹中的文件。

Service service = new Service();
    service.setMaintainSession(true);
    call    = (Call) service.createCall();
    call.setTargetEndpointAddress( new java.net.URL("<host>/_vti_bin/lists.asmx") );

    call.setOperationName(new QName("http://schemas.microsoft.com/sharepoint/soap/","GetListItems"));
    call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean("true"));
    call.setProperty(Call.SOAPACTION_URI_PROPERTY,"http://schemas.microsoft.com/sharepoint/soap/GetListItems");

  call.addParameter(new javax.xml.namespace.QName("http://schemas.microsoft.com/sharepoint/soap/", "listName"),
    new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"),
    java.lang.String.class,
    javax.xml.rpc.ParameterMode.IN);

   MessageElement me = 
        new MessageElement(new QName("QueryOptions"));
    me.addChildElement(new MessageElement(new QName(
    "IncludeMandatoryColumns"))).addTextNode("true");
    me.addChildElement(new MessageElement(new QName(
    "ViewAttributes"))).addAttribute(javax.xml.soap.SOAPFactory.newInstance().createName("Scope"), "Recursive");

    MessageElement[] me1 = {me}; 

    String strMyString = ""
        + "<Query>"
        + "<OrderBy><FieldRef Name=\"ows_Modified\" Ascending=\"TRUE\" /></OrderBy>"
        + "</Query>";

        MessageElement[] meArray = { getMeFromString(strMyString) };// Array


    call.addParameter("query",org.apache.axis.Constants.XSD_SCHEMA,
            javax.xml.rpc.ParameterMode.IN);    

    call.addParameter("queryOptions",org.apache.axis.Constants.XSD_SCHEMA,
            javax.xml.rpc.ParameterMode.IN);    

    call.setReturnType(org.apache.axis.Constants.XSD_SCHEMA);

   Schema ret = (Schema)call.invoke(new Object[] {"listGUID",meArray, me1 });


   public org.apache.axis.message.MessageElement getMeFromString(final String strMyString) {
    DocumentBuilder docBuilder = null;
    try {
        docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    } catch (final ParserConfigurationException e) {

        e.printStackTrace();
    } catch (final FactoryConfigurationError e) {

        e.printStackTrace();
    }
    final StringReader reader = new StringReader(strMyString);
    final InputSource inputsource = new InputSource(reader);
    Document doc = null;
    try {
        doc = docBuilder.parse(inputsource);
    } catch (final SAXException e) {
        e.printStackTrace();
    } catch (final IOException e) {
        e.printStackTrace();
    }
    final Element ele = doc.getDocumentElement();
    final MessageElement msg = new MessageElement(ele);

    return msg;
}

1 个答案:

答案 0 :(得分:0)

query.ViewAttributes =“Scope ='RecursiveAll'”