Victor Ferreira
Victor Ferreira

Reputation: 6449

Send an XML string via HTTP Post with cURL to a webservice

guys I'm trying to send an HTTP Post request to a webservice with raw/command line cURL passing an XML string

This is the XML I am trying to pass (values are fake)

<?xml version='1.0' encoding='UTF-8'?>
<soap-env:Envelope xmlns:soap-env='http://schemas.xmlsoap.org/soap/envelope/'>
<soap-env:Body>
    <m:F2bAcaoCobranca xmlns:m='http://www.f2b.com.br/soap/wsbillingaction.xsd'>
        <mensagem data='2005-04-18' numero='222555333'/>
        <cliente conta='90240728366170132' senha='54226484'/>
        <acao_cobranca numero='153079' cancelar_cobranca='1' registrar_pagamento='0' registrar_pagamento_valor='' dt_registrar_pagamento='' cancelar_multa='0' permitir_pagamento='0' dt_permitir_pagamento='' reenviar_email='0' email_tosend=''/>
        <acao_agendamento numero='123' cancelar_agendamento='0'/>
    </m:F2bAcaoCobranca>
</soap-env:Body>

And this is the webservice's URL

http://www.f2b.com.br/WSBillingAction

So I tried many things. Firstly I put the URL at the beginning and the XML string at the ending and it said the < wasn't expected as part of a URL. So I changed positions and this was the last attempt

curl -X POST -d "XML STRING" \ http://www.f2b.com.br/WSBillingAction

And now it says Protocol " http" not supported or disabled in libcurl

Any ideas on how to send this message?

Upvotes: 0

Views: 2775

Answers (1)

Daniel Stenberg
Daniel Stenberg

Reputation: 58244

Remove the backslash. You've added an escaped space first in the URL and a URL cannot contain a space!

A corrected line would look like:

curl -d "XML STRING" http://www.f2b.com.br/WSBillingAction

Or you store your XML in a file and you send it like

curl -d @xmlfile http://www.f2b.com.br/WSBillingAction

Upvotes: 2

Related Questions