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

后端 未结 8 538
失恋的感觉
失恋的感觉 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
    
    0 讨论(0)
  • 2020-11-30 17:46

    For Windows I found this working:

    Set http = CreateObject("Microsoft.XmlHttp")
    http.open "GET", "http://www.mywebservice.com/webmethod.asmx?WSDL", FALSE
    http.send ""
    WScript.Echo http.responseText
    

    Reference: CodeProject

    0 讨论(0)
  • 2020-11-30 17:50

    On linux command line, you can simply execute:

    curl -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:"  -d @your_soap_request.xml -X POST https://ws.paymentech.net/PaymentechGateway
    
    0 讨论(0)
  • 2020-11-30 17:57

    Here is another sample CURL - SOAP (WSDL) request for bank swift codes

    Request

    curl -X POST http://www.thomas-bayer.com/axis2/services/BLZService \
      -H 'Content-Type: text/xml' \
      -H 'SOAPAction: blz:getBank' \
      -d '
      <soapenv:Envelope 
        xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:blz="http://thomas-bayer.com/blz/">
        <soapenv:Header/>
        <soapenv:Body>
          <blz:getBank>
            <blz:blz>10020200</blz:blz>
          </blz:getBank>
        </soapenv:Body>
      </soapenv:Envelope>'
    

    Response

    < HTTP/1.1 200 OK
    < Server: Apache-Coyote/1.1
    < Content-Type: text/xml;charset=UTF-8
    < Date: Tue, 26 Mar 2019 08:14:59 GMT
    < Content-Length: 395
    < 
    <?xml version='1.0' encoding='UTF-8'?>
    <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
      <soapenv:Body>
        <ns1:getBankResponse
          xmlns:ns1="http://thomas-bayer.com/blz/">
          <ns1:details>
            <ns1:bezeichnung>BHF-BANK</ns1:bezeichnung>
            <ns1:bic>BHFBDEFF100</ns1:bic>
            <ns1:ort>Berlin</ns1:ort>
            <ns1:plz>10117</ns1:plz>
          </ns1:details>
        </ns1:getBankResponse>
      </soapenv:Body>
    </soapenv:Envelope>
    
    0 讨论(0)
  • 2020-11-30 17:57
    curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:ACTION_YOU_WANT_TO_CALL" --data @FILE_NAME URL_OF_THE_SERVICE 
    

    Above command was helpful for me

    Example

    curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:urn:GetVehicleLimitedInfo" --data @request.xml http://11.22.33.231:9080/VehicleInfoQueryService.asmx 
    

    More info

    0 讨论(0)
  • 2020-11-30 18:08

    It's a standard, ordinary SOAP web service. SSH has nothing to do here. I just called it with curl (one-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
    

    Where request.xml file has the following contents:

    <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>
    

    I get this beautiful 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>
    

    Have you tried soapui?

    Read more

    0 讨论(0)
提交回复
热议问题