Skip to content

addDocument #85

@jinngonqui

Description

@jinngonqui

Thanks for such a great API !

I am trying to update /SharePointAPI.php to allow me to use the Copy.asmx?WSDL for the CopyIntoItems feature. Extrapolation from the modifyList function is pretty straight forward ... until I think about the actual execution of the CAML.

I suspect I need a separate Copy.asmx?WSDL-based soapClient->UpdateListItems -- with UpdateListItems being replaced as well. Any guidance on how it should be changed to handle the Copy.asmx?WSDL, instead of the Lists.asmx?WSDL that modifyList uses?

I still have some other items to work through, but for now I am mostly interested in the "// Attempt to run operation" part -- that way I can troubleshoot the other stuff.

Here is what I have so far:

/**
 * addDocument
 * Perform an action on a sharePoint library to either add content to it.
 * This method will call the SharePoint SOAP API with this data
 * to apply the changes.
 *
 * @param $strSourceURL Externally where the file comes from ???
 * @param $strDestinationURL Internally where to put the file, what should this look like ???
 * @param $arrFields Associative Array with keys (DisplayName, InternalName, Id, Value)
 * @param $b64Stream byte-64 encoding of the Source file's contents
 * @return Array|Object
 */
public function addDocument ($strSourceURL, $strDestinationURL, array $arrFields, $b64Stream) {
    // Wrap in CAML
    $strType = 'File'; // see https://[domain].sharepoint.com/[[site]/[subsite]]/_vti_bin/Copy.asmx?WSDL for other Types
    $CAML = '
    <CopyIntoItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
        <SourceUrl>
            ' . $strSourceURL . '
        </SourceUrl>
        <DestinationUrls>
            <string>
                ' . $strDestinationURL . '
            </string>
        </DestinationUrls>
        <Fields>
            <FieldInformation>
                <Type>
                    ' . $strType . '
                </Type>
                <DisplayName>
                    ' . $arrFields['DisplayName'] . '
                </DisplayName>
                <InternalName>
                    ' . $arrFields['InternalName'] . '
                </InternalName>
                <Id>
                    ' . $arrFields['Id'] . '
                </Id>
                <Value>
                    ' . $arrFields['Value'] . '
                </Value>
            </FieldInformation>
        </Fields>
        <Stream>
            ' . $b64Stream . '
        </Stream>
    </CopyIntoItems>';
    $this->capturedCAML = $CAML;

    $xmlvar = new \SoapVar($CAML, XSD_ANYXML);
    $result = NULL;

    // Attempt to run operation
    try {
        //  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  vv  what should that be ????
        $result = $this->xmlHandler($this->soapClient->UpdateListItems($xmlvar)->UpdateListItemsResult->any);
    } catch (\SoapFault $fault) {
        $this->onError($fault);
    }

    // Return a XML as nice clean Array
    return $result;
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions