I successfully authenticated connection to my web service, I wrote in asp.net with PHP.
PHP codes:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
$soapURL = 'http://localhost:49280/orhan.asmx?WSDL';
$username = 'test';
$password = 'test';
$client = new SoapClient($soapURL);
$auth = new stdClass();
$auth->Username = $username;
$auth->Password = $password ;
$header = new SoapHeader('http://tempuri.org/', 'AuthHeader', $auth, true);
$client->__setSoapHeaders($header);
$response = $client->HelloWorld();
$xml = $response->HelloWorldResult;
echo ""
;
var_dump($xml);
echo "
";
This website if the authenticated is true printing hello world
, or authenticated is wrong, printing password or username is wrong
. Everything is fine and the program runs smoothly. But when I try to authenticate with python, unfortunately, appears on the console.
Python Code:
from requests.auth import HTTPBasicAuth # or HTTPDigestAuth, or OAuth1, etc.
from requests import Session
from zeep import Client
from zeep.transports import Transport
wsdl='http://localhost:49280/orhan.asmx?WSDL'
user = 'test'
password = 'test'
session = Session()
session.auth = HTTPBasicAuth(user, password)
client = Client(wsdl,
transport=Transport(session=session))
How do I get the string to appear on the console after authenticating in python?