omegahat / RCurl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with RCurl_SOAP Request with Attachment

KarthikDG opened this issue · comments

I am trying for a SOAP request with an attachment but without success.
For the code below, I am getting the status as HTTP 1.1 200 OK but with the response as no attachment.
Could you please check and let me know whether I am missing anything.Thanks in advance.

library(RCurl)
library(XML)

body = '
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inc="http://www.XXXXXXX.com/XXX/soap/incomingcommunicationservice" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:type="http://www.XXXXXXX.com/XXX/soap/incomingcommunicationservice/type">
soapenv:Header/
soapenv:Body
inc:storeIncomingCommunication
type:storeIncomingCommunicationRequest
type:incomingCommunication
type:claimRef
type:externalIdentifier1111111</type:externalIdentifier>
</type:claimRef>
type:isFinishedfalse</type:isFinished>
type:userTaskTypeRef
type:externalIdentifierCAESCorrespondentie</type:externalIdentifier>
</type:userTaskTypeRef>
type:documentList

type:document
type:documentIdentifierInExtSys100</type:documentIdentifierInExtSys>
type:documentTypeRef</type:documentTypeRef>
type:areContentsStoredInExtSysfalse</type:areContentsStoredInExtSys>
type:isSignedfalse</type:isSigned>
type:filenameimage001.pdf</type:filename>
type:inboundReturnDocumentIdentifier/
</type:document>

</type:documentList>
type:origin
type:initialsX.X.</type:initials>
type:nameXXX XXXXX</type:name>
type:cityXXXXXXXX</type:city>
type:postalCode1111XX</type:postalCode>
type:houseNumber11</type:houseNumber>
type:houseNumberExtension?</type:houseNumberExtension>

type:unstructuredHouseNumber?</type:unstructuredHouseNumber>
type:streetNameXXXXXXXX XXXXXX</type:streetName>
type:claimRoleRef
type:externalIdentifierXXX</type:externalIdentifier>
</type:claimRoleRef>
</type:origin>
type:dateReceived2017-11-06</type:dateReceived>
type:emailSubjectXXXXXX XXXXX XXXX</type:emailSubject>
type:emailBodyXXXXXXXXXXX</type:emailBody>
type:descriptionXXXXXXXXXXXXX</type:description>
type:emailAddressXXXXXXXXXXXX</type:emailAddress>
type:isComplaintfalse</type:isComplaint>
type:containsMedicalInformationfalse</type:containsMedicalInformation>
type:containsConfidentialInformationfalse</type:containsConfidentialInformation>
type:isMatterOfFraudfalse</type:isMatterOfFraud>
type:communicationTypeRefEmail</type:communicationTypeRef>
type:hasPriorityfalse</type:hasPriority>
type:containsDocumentsInExtSystemfalse</type:containsDocumentsInExtSystem>

</type:incomingCommunication>
</type:storeIncomingCommunicationRequest>
<type:document1 href="image001.pdf"/>
</inc:storeIncomingCommunication>
</soapenv:Body>
</soapenv:Envelope>
'
reader = basicTextGatherer()

options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"), followlocation = TRUE, httpheader = c(Accept = "text/xml",Accept = "multipart/*",'Content-Type' = "text/xml; charset=utf-8", SOAPAction="INTRANET URL"), userpwd = "USERID:PASSWORD", netrc = TRUE,timeout = 100, postfields = body, writefunction = reader$update, verbose=TRUE,httpauth=AUTH_BASIC))

response_IncomingCommunicationService <- getForm("INTRANET URL",
file = fileUpload(filename = "C:\Users\USERNAME\Desktop\image001.pdf", contentType = "application/pdf"),upload=TRUE)

response_IncomingCommunicationService_html <- htmlTreeParse(response_IncomingCommunicationService)$children$html

response_IncomingCommunicationService_html
closeAllConnections()