2
votes

I am trying to implement soap calls testing through Robot framework.Tried various solutions that I could find on google, nothing works.

The same is working when I am testing through SOAP UI. Am I missing something , I am not sure.

new test
             [Tags]               abcd
             Add Doctor Import    http://schemas.xmlsoap.org/soap/encoding/
             &{headers}=          Create Dictionary                            Content-Type                                                                                     text/xml                                                            SOAPAction             ""                    Host    bfx-b2b....
             ${auth}=             Create List                                  Test                                                                                    Password3#
             Create Session       getPlans                                     https://bfx-b2b.../wsdl/ProductService.wsdl    auth=${auth}                                                        verify=True
             ${file_data}=        Get Binary File                              ${CURDIR}/request.xml
             Log                  ${file_data}
             ${byte_string}=      Encode String To Bytes                       ${REQUEST}                                                                                       UTF-8
             ${resp}=             Post Request                                 getPlans                                                                                         https://bfx-b2b..../B2BWEB/services/IProductPort    data=${byte_string}    headers=${headers}
             Log                  ${resp.text}
             Log                  ${resp.status_code}

I am getting below 500 error in response.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 [email protected] and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

Few Soap UI details -

Endpoint that I am hitting on SOAP UI -https://bfx-b2b.../B2BWEB/services/IProductPort Raw data -

POST https://bfx-b2b.../B2BWEB/services/IProductPort HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Content-Length: 1822
Host: bfx-b2b...
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Cookie: SMCHALLENGE=YES
Cookie2: $Version=1
Authorization: Basic V2VsbHRoaWVfVGVzdDpQYXNzd29yZDMj
1
What happens if you change from this in the headers dict: SOAPAction "" to this: SOAPAction ${EMPTY}. The thing is, the first way (the one in your sample) will create a string value that is 2 quotes; when the call is to be made, the library will escape them, e.g. the header most probably looks like this - SOAPAction: "\"\"", which is probably not what you want. The second way - the one using ${EMPTY}, will generate a header in the actual call SOAPAction: "" - e.g. what you most probably expect. - Todor Minakov
Yes ,the header has changed but the output is still the same. Status code 500. - themaster
It would be good to understand what you've tried and what your results where. Otherwise we may be proposing solutions that won't work for you. In any case I've had some success with the SudsLibrary where I use it to send the XML that I crafted using the XML library. - A. Kootstra

1 Answers

0
votes

See if this example will help you:

*** Settings ***
Documentation     Test with SOAP (WSDL) with two parameters that returns the country passing the IP
Library           SudsLibrary

*** Variables ***
${ip}             150.162.2.1

*** Test Cases ***
ConsultaIP
    Create Soap Client    http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl
    ${result}    Call Soap Method    ResolveIP    ${ip}    null
    ${country}    Get Wsdl Object Attribute    ${result}    Country
    ${Latitude}    Get Wsdl Object Attribute    ${result}    Latitude
    ${Longitude}    Get Wsdl Object Attribute    ${result}    Longitude
    log    The IP ${ip} belongs to the country ${country}, Latitude: ${Latitude} Longitude: ${Longitude}