1

When I'm uploading a file to SharePoint 2010 using soap webservice, I'm getting a Error Code like

Destination Invalid

My Request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.microsoft.com/sharepoint/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap:CopyIntoItems>         <soap:SourceUrl>C:\Users\system30\Desktop\icons\employee.jpg</soap:SourceUrl>
<soap:DestinationUrls>
<soap:string>http://192.168.20.123:80/Shared Documents/employee.jpg</soap:string>
</soap:DestinationUrls>
<soap:Fields>
<soap:FieldInformation Type="Text" DisplayName="Description" InternalName="Description" Value="sample"/>
</soap:Fields>
<soap:Stream>here my endoded string(base64)</soap:Stream>
</soap:CopyIntoItems>
</soapenv:Body>
</soapenv:Envelope>          

And I'm getting the following error code when executing

Response:

<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>
<CopyIntoItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<CopyIntoItemsResult>0</CopyIntoItemsResult>
<Results>
<CopyResult ErrorCode="DestinationInvalid" ErrorMessage="The Copy web service method must be called on the same domain that contains the destination url." DestinationUrl="http://192.168.20.123:80/Shared Documents/employee.png"/>
</Results>
</CopyIntoItemsResponse>
</soap:Body>
</soap:Envelope>

And permission for my site is like this

1

plz find below code snippet it will help you to get resolve you file uploading issue

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script><script src="http://sp:2000/sites/ex1/Style%20Library/JSFiles/jquery.SPServices-0.6.2.min.js" type="application/javascript"></script><script src="http://code.jquery.com/jquery-1.6.min.js" type="text/javascript"></script>
<script type="text/javascript">
   function uploadFile() {

    var filePath = "‪C:\\Users\sp_admin\Desktop\MYDOC.docx";
    //I have alredy Create Doc on below path for testing  purposer
    **var url= "http://sp:2000/sites/ex1/TestDocUplode/MYDOC.docx";**

    var soapEnv =
    "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \
        <soap:Body>\
            <CopyIntoItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>\
                <SourceUrl>" + filePath + "</SourceUrl>\
                    <DestinationUrls>\
                        <string> "+ url + "</string>\
                    </DestinationUrls>\
                    <Fields>\
                        <FieldInformation Type='Text' DisplayName='Title' InternalName='Title' Value='Test' />\
                    </Fields>\
                <Stream>base64Binary</Stream>\
            </CopyIntoItems>\
        </soap:Body>\
    </soap:Envelope>";

    $.ajax({
        url: "http://sp:2000/sites/ex1/_vti_bin/copy.asmx",
        beforeSend: function (xhr) { xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/CopyIntoItems"); },
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: processResult,
        contentType: "text/xml; charset=\"utf-8\""
    });
    alert(soapEnv);
}
function processResult(xData, status) {
    alert("Uploaded SuccessFully");
}
 </script>
<input name="Upload" value="Upload" onclick="uploadFile()" type="button"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.