Soap Calls using Robot Framework - python-requests

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,
ESS_eBiz_Operations#uhc.com 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

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}

Related

Robotframework: Request - POST request with JSON body on demo REST site gives 400

The 'dummy.restapiexample.com' site provides a nice demo REST service. Retrieving data is simple in Robotframework via de Request library.
Creating a body with dictionaries works! When I use JSON bodies, I get these errors.
Test 1: POST to reqres.in gives http status: 400
*** Settings ***
Library RequestsLibrary
*** Variables ***
${RestApiB} = https://reqres.in
*** Test Cases ***
Create a new user
Create Session restSession ${RestApiB}
${jsonString} = To Json {"name":"jjxx","job":"devxx"}
${headers} = Create Dictionary Content-Type=application/json
${response} = Post Request restSession /api/users json=${jsonString} headers=${headers}
Should Be Equal As Strings ${response.status_code} 201

Netscaler monitoring custom headers

I'm trying to setup monitoring (http-ecv) with authorization header, but I'm getting illegal character or header folding error (jetty 9.3)
1. example
GET /somepath/somepage.html HTTP/1.1
Server Running
\r\nAuthorization: Basic somestring=\r\n
Response "HTTP1.1 400 Illegal character SPACE=''\r\n"
2. example
GET /somepath/somepage.html
Server Running
HTTP/1.1\r\nAuthorization: Basic somestring=\r\n
Response HTTP/1.1 400 Illegal character VCHAR='/'\r\n
This example was working on older jetty version
3.example
GET /somepath/somepage.html
Server Running
\r\nHTTP/1.1\r\nAuthorization: Basic somestring=\r\n
Response HTTP1.1 400 Header Folding\r\n
Any ideas?
try the solution on the article https://support.citrix.com/article/CTX117142
edit to add more context: the article describes how to create a monitor for a back end server that requests basic authentication with a user name and password.
Summarized:
add lb monitor test_login_tcp TCP-ECV -send "GET / HTTP/1.1\r\nAuthorization: Basic YOURBASE64USERPW\r\nHost: IP_or_FQDN\r\n\r\n" -recv 200 -LRTM ENABLED

AT commands Quectel MC60

I've just started working with the Quectel MC60 and I am having some issues:
About HTTP GET method, I make the following commands:
AT+QIFGCNT=0
AT+QICSGP=1,"my_apn"
AT+QIREGAPP
AT+QIACT
AT+QSSLCFG="https",1
AT+QHTTPURL=39,40
my_url_39_bytes_long
AT+QHTTPGET=60
AT+QHTTPREAD=30
AT+QIDEACT
When using the QCOM software, I make a script running all the above commands sequentially. When it comes to the AT+QHTTPREAD command, the response is always "+CME ERROR: 3822" (HTTP response failed). What can it be? I'm sure the HTTP server is working properly.
The answer is that it is necessary to configure the request header
AT+QIFGCNT=0
AT+QICSGP=1,"my_apn"
AT+QIREGAPP
AT+QIACT
AT+QHTTPURL=39,40
my_url_39_bytes_long
AT+QHTTPCFG="requestheader",1
AT+QHTTPPOST=77
GET path HTTP/1.1
User-Agent: Fiddler
Host: www.my_host.com
AT+QHTTPREAD=30
AT+QIDEACT
NOTE: in AT+HTTPPOST=77, 77 is the size of the POST message (last two \r\n are required and count)
NOTE2: after GET you're supposed to write the path to the url inserted in AT+QHTTPURL. For example, if you specified your URL as https://www.my_host.com/debug/main/port, your AT+HTTPPOST request should look like this (don't forget the last two \r\n):
GET /debug/main/port HTTP/1.1
User-Agent: Fiddler
Host: www.my_host.com

How to set header in robot framework for HttpLibrary.HTTP

How to set the header as content-type and authentication for robotframework
*** Variables ***
${PORT} 36504
${HOST} https://staging-product..co/api/products
${HeaderName} Content-Type
${HeaderValue} application/json
${HeaderName1} Authorization
${HeaderValue1} Token token=zkzg1VPnhcMm7uv,email=cctest7#gmail.com
*** Settings ***
Resource variables.txt
Library HttpLibrary.HTTP
Test Setup Create HTTP Context ${HOST} https
*** Test Cases ***
Set Headers
POST https://staging-product..co/api/products
Full-URL GET to MytestSsite
GET https://staging-product.connect.co/
Taken from the HTTP Library Documentation (https://peritus.github.io/robotframework-httplibrary/HttpLibrary.html)
Set Request Header | header_name, header_value |
Sets a request header for the next request.
header_name is the name of the header, e.g. User-Agent header_value is the key of the header, e.g. RobotFramework HttpLibrary (Mozilla/4.0)
A further simple example would be:
Set Request Header Content-Type application/json
or using your variables above:
Set Request Header ${HeaderName} ${HeaderValue}
Here is a full example:
Create HTTP Context ${HOST} http
${Request_Body} Get File ${xmlFilename} encoding=${Request_Body_Encoding}
Set Request Header ${HeaderName} ${HeaderValue}
Set Request Body ${Request_Body}
Log ${Request_Body}
POST ${URL}
Response Status Code Should Equal ${ResponseStatusCode}

Digest Authentication for ROBOTFRAMEWORK

below is the begining of a script for testing a rest interface on a device , this device has a https server with Digest Authentication.
This is where i am encountering a problem below I have it set up I do not get an error so i assume
Set Digest Auth admin secret is valid
if it is what can I not authenticate:
#script
*** Settings ***
Resource variablesreal.txt
Library HttpLibrary.HTTP
Library PycURLLibrary
Library OperatingSystem
Test Setup Create HTTP Context ${HOST} https
*** Variables ***
${HEADER1} Content-Type: text/xml; charset=UTF-8
*** Test Cases ***
Set Digest Auth
Log Variables
Verbose
Add Header ${HEADER1}
Add Header version:1
Next Request Should Not Succeed
GET https://${HOST}/views
Set Digest Auth admin secret
GET https://${HOST}/views
Response Status Code Should Equal 200
Response Body Should Contain views
Log Response Status
Log Response
here is the out put from pybot hls.txt
==============================================================================
Hls
==============================================================================
Set Digest Auth | FAIL |
Request should have succeeded, but was "401 Unauthorized".
------------------------------------------------------------------------------
Hls | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output: /home/robm/code/BDD/pycurl/hl/output.xml
Log: /home/robm/code/BDD/pycurl/hl/log.html
Report: /home/robm/code/BDD/pycurl/hl/report.html
any ideas on Digest authentication?
I ended up adding this to RequestKeywords.py
def create_digest_session(self, alias, url, auth, headers={}, cookies=None, timeout=None, proxies=None, verify=False):
""" Create Session: create a HTTP session to a server
`url` Base url of the server
`alias` Robot Framework alias to identify the session
`headers` Dictionary of default headers
`auth` List of username & password for HTTP Digest Auth
`timeout` connection timeout
`proxies` proxy server url
`verify` set to True if Requests should verify the certificate
"""
digest_auth = requests.auth.HTTPDigestAuth(*auth) if auth else None
return self._create_session_local(alias, url, headers, cookies, digest_auth, timeout, proxies, verify)

Resources