How to do a SOAP wsdl web services call from the command line

后端 未结 8 544
失恋的感觉
失恋的感觉 2020-11-30 17:40

I need to make a SOAP webservice call to https://sandbox.mediamind.com/Eyeblaster.MediaMind.API/V2/AuthenticationService.svc?wsdl and to use the operation ClientLogin while

8条回答
  •  天命终不由人
    2020-11-30 17:46

    Using CURL:

    SOAP_USER='myusername'
    PASSWORD='mypassword'
    AUTHENTICATION="$SOAP_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
    

    I use this to verify response:

    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: $SOAP_USER Password: $PASSWORD Press any key to continue..."
    read entervalue || continue
    fi
    

提交回复
热议问题