Я смог заставить его работать с вашими предложениями:
Вот полный сценарий, который я использую: который использует запрос SOAP для проверки номеров НДС в ЕС с помощью http://ec.europa.eu/taxation_customs/vies/checkVatService.wsd
VatCheck <- function(x,z)
{
get_config_proxy <- function(url, user = NULL, pwd = NULL, verbose = FALSE, auth = "basic") {
# curl::ie_get_proxy_for_url wants a scheme - either way it don't work
if(is.null(httr::parse_url(url)$scheme)) {
if (verbose) message("No scheme provided. assume HTTP")
url <- modify_url(url, scheme = "http")
}
# get the proxy url if needed
proxy_url <- curl::ie_get_proxy_for_url(url)
# return blank config if no proxy required
if(is.null(proxy_url)) {
if(verbose) message("No proxy")
return(httr::config())
}
if(verbose) message("Proxy found")
# Otherwise configure the proxy / user and password are needed
# return a config object for use with httr
proxy_config <- httr::use_proxy(url = proxy_url, auth = auth)
}
body = sprintf("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:ec.europa.eu:taxud:vies:services:checkVat:types'>
<soapenv:Body>
<urn:checkVat xmlns='urn:ec.europa.eu:taxud:vies:services:checkVat:types'>
<urn:countryCode>%s</urn:countryCode>
<urn:vatNumber>%s</urn:vatNumber>
</urn:checkVat>
</soapenv:Body>
</soapenv:Envelope>",x,z)
url <- "http://ec.europa.eu/taxation_customs/vies/services/checkVatService"
# No proxy configured so we get a timeout from curl fetch
# req <- GET(url)
# we configure the proxy giving interactively user and password
config_proxy <- get_config_proxy(url)
# we make a GET using the config
x <- with_config(config_proxy, POST(url, body=body))
req<-toString(content(x)) # we get 200. it works!
req
}
for(i in 1:nrow(input)) {
input[i, "Valid"] <- VatCheck(x = toString(input[i, "Column1"]) , z= toString(input[i, "Colum2"]))
}
output <- input