You need to sign in to do that
Don't have an account?
Web service callout failed: Unable to parse callout response - Amazon S3 CopyObject
Hi,
I am trying to integrate Amazon S3 and salesforce. I have created an Apex class from the S3 WSDl using WSDL2Apex. When the S3 copyObject method is invoked, I get the following exception
System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element http://s3.amazonaws.com/doc/2006-03-01/=CopyObjectResponse
However, the object copy from one bucket to another is successful. Can somebody help me with understanding this exception?
I tried debugging the using Force.com IDE and the response seems to be the one expected for a successful COPY operation.
Have you installed the Force.com for Amazon Web Services toolkit which includes the S3 apex class to invoke S3 web services.
The copyObject method is not specifically implemented yet, but you should see all the objects and web service methods commented out in the S3 class.
I get the same error when I uncomment the CopyObject related code in the Amazon toolkit and invoke the CopyObject method. Here's the debug log from Force.com IDE -
DEBUG LOG
20090304181936.038:AnonymousBlock: line 1, column 21: returning from end of method public AmazonS3<Constructor>(String, String) in 0 ms
20090304181936.038:AnonymousBlock: line 2, column 149: returning String from method public String signature(String, Datetime) in 1 ms
20090304181936.038:Class.S3.AmazonS3.CopyObject: line 537, column 13: Created Web Service callout to endpoint: https://s3.amazonaws.com/soap
20090304181936.038:Class.S3.AmazonS3.CopyObject: line 537, column 13: Sending callout request
20090304181936.038:Class.S3.AmazonS3.CopyObject: line 537, column 13: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header /><env:Body><CopyObject xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><SourceBucket>Bucket1</SourceBucket><SourceKey>180.doc</SourceKey><DestinationBucket>Bucket2</DestinationBucket><DestinationKey>201.doc</DestinationKey><MetadataDirective>COPY</MetadataDirective><AWSAccessKeyId>xxxxxxx</AWSAccessKeyId><Timestamp>2009-03-04T18:19:36.043Z</Timestamp><Signature>skZI149rL2IAbWF1UJB8yoHulGk=</Signature></CopyObject></env:Body></env:Envelope>
20090304181936.038:Class.S3.AmazonS3.CopyObject: line 537, column 13: Reading callout response
20090304181936.038:Class.S3.AmazonS3.CopyObject: line 537, column 13: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"><soapenv:Header><wsa:MessageID soapenv:mustUnderstand="0">uuid:057b1c50-08e9-11de-8570-f1ad314825ad</wsa:MessageID><wsa:To soapenv:mustUnderstand="0">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To></soapenv:Header><soapenv:Body><CopyObjectResponse xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><CopyObjectResponse xsi:type="ns1:CopyObjectResult" xmlns:ns1="http://s3.amazonaws.com/doc/2006-03-01/"><LastModified>2009-03-04T18:19:37.000Z</LastModified><ETag>"bcec79969e242ce0341f9931b982c611"</ETag></CopyObjectResponse></CopyObjectResponse></soapenv:Body></soapenv:Envelope>
System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element http://s3.amazonaws.com/doc/2006-03-01/=CopyObjectResponse
Hi Trish,
How did you manage to output this in your debug log? mine just says this
20090901072124.104:Class.Customers.CustomersSoap.AddCustomer: line 87, column 13: Sending callout request
20090901072124.104:Class.Customers.CustomersSoap.AddCustomer: line 87, column 13: Reading callout response
Hi Maxa,
I did the debugging using the "Execute Anonymous" feature on Force.com IDE. Details are in the link below.
http://wiki.developerforce.com/index.php/Apex_Web_Services_and_Callouts. Look for the section Debugging WSDL2Apex
I'm also receiving this error using the S3 toolkit as supplied by Salesforce. The problem as far as I can see is exactly what the error states. The salesforce XML parser doesn't support the XML being returned.
Its beyond me why this Salesforce bug is not being fixed urgently.
Sorry I do realise this is an old post but did anyone end up finishing off the commented out functions in the apex-aws class.
I am particually looking for a working version of
public S3.GetObjectResult GetObject
I got it all working fine, but then I ended up running into all of the Governor Limits of 100Kb I think its 1Mb now and timeout limits for any decent sized file.
My final solution was instead to: use an external service to upload the file, and only use apex/visualforce to generate a presigned URL and redirect the users browser to that URL. So I do not use SOAP/WebService calls from APEX at all.
There are few mistakes in S3 class provided by Amazon toolkit.
Replace following class in your S3 class.
-----------------------------------------------------------------------------------------------------------------
public class CopyObjectResponse_element {
public S3.CopyObjectResult CopyObjectResponse;
private String[] CopyObjectResponse_type_info = new String[]{'CopyObjectResponse','http://s3.amazonaws.com/doc/2006-03-01/','CopyObjectResult','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://s3.amazonaws.com/doc/2006-03-01/','true'};
private String[] field_order_type_info = new String[]{'CopyObjectResponse'};
}
------------------------------------------------------------------------------------------------------------
public S3.CopyObjectResult CopyObject(String SourceBucket,String SourceKey,String DestinationBucket,String DestinationKey,String MetadataDirective,S3.MetadataEntry[] Metadata,S3.AccessControlList AccessControlList,DateTime CopySourceIfModifiedSince,DateTime CopySourceIfUnmodifiedSince,String[] CopySourceIfMatch,String[] CopySourceIfNoneMatch,String StorageClass,String AWSAccessKeyId,DateTime Timestamp,String Signature,String Credential) {
S3.CopyObject_element request_x = new S3.CopyObject_element();
S3.CopyObjectResponse_element response_x;
request_x.SourceBucket = SourceBucket;
request_x.SourceKey = SourceKey;
request_x.DestinationBucket = DestinationBucket;
request_x.DestinationKey = DestinationKey;
request_x.MetadataDirective = MetadataDirective;
request_x.Metadata = Metadata;
request_x.AccessControlList = AccessControlList;
request_x.CopySourceIfModifiedSince = CopySourceIfModifiedSince;
request_x.CopySourceIfUnmodifiedSince = CopySourceIfUnmodifiedSince;
request_x.CopySourceIfMatch = CopySourceIfMatch;
request_x.CopySourceIfNoneMatch = CopySourceIfNoneMatch;
request_x.StorageClass = StorageClass;
request_x.AWSAccessKeyId = AWSAccessKeyId;
request_x.Timestamp = Timestamp;
request_x.Signature = Signature;
request_x.Credential = Credential;
Map<String, S3.CopyObjectResponse_element> response_map_x = new Map<String, S3.CopyObjectResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://s3.amazonaws.com/doc/2006-03-01/',
'CopyObject',
'http://s3.amazonaws.com/doc/2006-03-01/',
'CopyObjectResponse',
'S3.CopyObjectResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.CopyObjectResponse;
}
Hope this will help you.
Thanks,
Anil
1. Create Amazon S3 file for standard Salesforce attachment through
trigger.
2. Upload attachments on Amazon S3 and create reference in Salesforc to
access those attachments
3. Attach file related to any Salesforce object on Amazon.
4. Unlimited free storage.
5. Auto backup Event logs / inbound email attachments.
6. Server Side Encryption: AES-256
7. No file size limit for upload.
8. File access control capabiliy.
9. Track file downloads by users.
10. File exlorer capability.
https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000CW1OXEA1
Here is our email address. Let us know if you have any query.
support@neiloncloud.com
Thanks.