andrewmcgivery / angular-soap

An angular port of a Javascript SOAP Client into a factory that has a similar syntax to $http.
114 stars 84 forks source link

SharePoint 2010 Response is Not Handled #10

Open gamelover42 opened 9 years ago

gamelover42 commented 9 years ago

I am working with the SharePoint 2010 Copy Web service, specifically with a "POST" to the "CopyIntoItemsLocalResponse" method (but I suspect the rest behave the same way).

There are a few response scenarios that are not handled with the default client. First if the results come back from the service with an error then I simply get a "0" in the success handler. It's not obvious from the xml below but the Copy.asmx service returns http status 200 for these two errors.

Sample1

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <CopyIntoItemsLocalResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
            <CopyIntoItemsLocalResult>0</CopyIntoItemsLocalResult>
            <Results>
                <CopyResult ErrorCode="DestinationInvalid" ErrorMessage="Cannot create an item at the requested destination.  Verify that the folder exists and that you have permission to edit in it." DestinationUrl="http://server/sites/mysite/reportlist/thefile/file.xlsx" />
            </Results>
        </CopyIntoItemsLocalResponse>
    </soap:Body>
</soap:Envelope>

Sample 2

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <CopyIntoItemsLocalResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
            <CopyIntoItemsLocalResult>0</CopyIntoItemsLocalResult>
            <Results>
                <CopyResult ErrorCode="Unknown" ErrorMessage="Invalid URI: The format of the URI could not be determined." DestinationUrl="/sites/mysite/reportlist/foo.xlsx" />
            </Results>
        </CopyIntoItemsLocalResponse>
    </soap:Body>
</soap:Envelope>

Lastly, similarly with the success message I simply get the "0" and not the "results" node. Sample 3

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <CopyIntoItemsLocalResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
            <CopyIntoItemsLocalResult>0</CopyIntoItemsLocalResult>
            <Results>
                <CopyResult ErrorCode="Success" DestinationUrl="http://server/sites/mysite/reportlist/foo.xlsx" />
            </Results>
        </CopyIntoItemsLocalResponse>
    </soap:Body>
</soap:Envelope>