Converting PHP soap client to Python

369 views Asked by At

I'm trying to use a SOAP API,but the docs and the examples are all written in PHP. this is the PHP sample:

<?php

$client = new SoapClient('http://beta.payamsms.com/wsdl?t='.time(), array(
    'location' => 'http://beta.payamsms.com/soap',
    'uri'      => 'http://beta.payamsms.com/soap',
    'use'      => SOAP_LITERAL,
    'style'    => SOAP_DOCUMENT,
    'trace'    => 1
));

//Get customer's balance
$response = $client->getBalance(array(
    'userName'=>'bWvVCxNSeovqJviz7mzZqQ', 
    'password' => '123654789', 
    'facilityId' => 1
));
echo 'Your balance is: ' . $response->getBalanceReturn->balance . PHP_EOL;
echo PHP_EOL;

This is my python code:

import time
from suds.client import Client
from suds.xsd.doctor import Import, ImportDoctor


service = "http://beta.payamsms.com/wsdl?t="+int(time.time()).__str__()
doctor = Import("http://beta.payamsms.com/soap")
client = Client(service, doctor=ImportDoctor(doctor))
client_service = client.service.getBalance(userName='bWvVCxNSeovqJviz7mzZqQ', password='123654789', facilityId=1)

But i keep getting Exception: (405, 'Not Allowed') error.

So, what should i do next?

0

There are 0 answers