Comment faire un appel SOAP WSDL web services depuis la ligne de commande
je dois faire un appel webservice SOAP à https://sandbox.mediamind.com/Eyeblaster.MediaMind.API/V2/AuthenticationService.svc?wsdl et d'utiliser L'opération ClientLogin en passant par les paramètres: ApplicationKey, Password, et UserName. La réponse est la sécurité des utilisateurs. Elles sont toutes les chaînes.
voici le lien expliquant pleinement ce que j'essaie de faire: https://sandbox.mediamind.com/Eyeblaster.MediaMind.API.Doc/?v=3
Comment puis-je faire cela en ligne de commande? (Windows et/ou Linux seraient utiles)
6 réponses
c'est un service SOAP Web standard, ordinaire. SSH n'a rien à faire ici. Je viens de l'appeler avec curl (un-liner):
$ curl -X POST -H "Content-Type: text/xml" \
-H "SOAPAction: \"http://api.eyeblaster.com/IAuthenticationService/ClientLogin\"" \
--data-binary @request.xml \
https://sandbox.mediamind.com/Eyeblaster.MediaMind.API/V2/AuthenticationService.svc
Où request.xml
fichier a le contenu suivant:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://api.eyeblaster.com/">
<soapenv:Header/>
<soapenv:Body>
<api:ClientLogin>
<api:username>user</api:username>
<api:password>password</api:password>
<api:applicationKey>key</api:applicationKey>
</api:ClientLogin>
</soapenv:Body>
</soapenv:Envelope>
je reçois cette belle 500:
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode>s:Security.Authentication.UserPassIncorrect</faultcode>
<faultstring xml:lang="en-US">The username, password or application key is incorrect.</faultstring>
</s:Fault>
</s:Body>
</s:Envelope>
avez-vous essayé soapui ?
sur la ligne de commande linux, vous pouvez simplement exécuter:
curl -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:" -d @your_soap_request.xml -X POST https://ws.paymentech.net/PaymentechGateway
utilisant CURL:
USER='myusername'
PASSWORD='mypassword'
AUTHENTICATION="$USER:$PASSWORD"
URL='http://mysoapserver:8080/meeting/aws'
SOAPFILE=getCurrentMeetingStatus.txt
TIMEOUT=5
CURL request:
curl --user "${AUTHENTICATION}" --header 'Content-Type: text/xml;charset=UTF-8' --data @"${SOAPFILE}" "${URL}" --connect-timeout $TIMEOUT
je l'utilise pour vérifier la réponse:
http_code=$(curl --write-out "%{http_code}\n" --silent --user "${AUTHENTICATION}" --header 'Content-Type: text/xml;charset=UTF-8' --data @"${SOAPFILE}" "${URL}" --connect-timeout $TIMEOUT --output /dev/null)
if [[ $http_code -gt 400 ]]; # 400 and 500 Client and Server Error codes http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
then
echo "Error: HTTP response ($http_code) getting URL: $URL"
echo "Please verify parameters/backend. Username: $USER Password: $PASSWORD Press any key to continue..."
read entervalue || continue
fi
Pour Windows:
enregistrer ce qui suit comme MSFT.vbs:
set SOAPClient = createobject("MSSOAP.SOAPClient")
SOAPClient.mssoapinit "https://sandbox.mediamind.com/Eyeblaster.MediaMind.API/V2/AuthenticationService.svc?wsdl"
WScript.Echo "MSFT = " & SOAPClient.GetQuote("MSFT")
puis, à partir d'une invite de commande, Exécuter:
C:\>MSFT.vbs
référence: http://blogs.msdn.com/b/bgroth/archive/2004/10/21/246155.aspx
Pour Windows, j'ai trouvé ce travail:
Set http = CreateObject("Microsoft.XmlHttp")
http.open "GET", "http://www.mywebservice.com/webmethod.asmx?WSDL", FALSE
http.send ""
WScript.Echo http.responseText
Référence: Projet COD
curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:ACTION_YOU_WANT_TO_CALL" --data @FILE_NAME URL_OF_THE_SERVICE
au-dessus du commandement m'a été utile
exemple
curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:urn:GetVehicleLimitedInfo" --data @request.xml http://11.22.33.231:9080/VehicleInfoQueryService.asmx